mysql - learning record

show databases; // list all databases

select databases; // display the current database

create database database name; // create a database

drop database database name; // delete the database

show full tables; // View table structure (Display all)

show open tables; // include cache table and open when the non-temporary table 

show table status; // Display status

DDL:

create database test character set utf8; // create the database and set the character set

alter table table add Column Name Data Type; // add a

desc table name; // Check table field information

alter table table name drop column names; // delete a

rename table the original table name to the modified name; // modify the table name

show cretae table table name; // see the table creation statements

alter table table name character set encoding; // Modify Character Encoding

alter table change table column names new original Column Name Data Type; // Modify Listing 

drop table table name; // Delete table

 

DML:

insert into table (table columns) values ​​(); // Insert

set update table column name = value where the new condition; // Review

delete from table [where name = Column column value]; // delete

truncate table table name; // Empty Table

1. delete the data deleted table, the table structure is still, you can retrieve deleted data

2. truncate table to delete, right directly drop, and then create a new table of the same, can not recover deleted data, perform faster than delete,

The reason execute faster:

Because delete delete delete process is that each row from the table, and at the same time the behavior of the delete operation and then saved as a transaction log records for rollback

truncate then delete all data from a table

 

Paradigm:

The first paradigm: Each column of the data table (Attribute) are substantially inseparable data items, each of each column of data are required to store only a single value, but

The second paradigm: all data requirements of every data table and the primary key of the data are entirely dependent relationship

Third Normal Form: All non-key attributes and only candidate key correlated, which means that all non-key attributes should be independent of each other.

 

Anti paradigm:

Trying to process the redundant data, or by increasing the data packets to optimize the database reads of

 

show varianles like '% query_log%'; see slow log is turned on (all over log_query_time seconds execution time sql statement will be recorded in the slow query log)

 

Guess you like

Origin www.cnblogs.com/daijiabao/p/11295371.html