Checklist
Check table table_name;
Repair table
Repair table table_name;
Optimization table
Optimize table table_name;
Analysis table
Analyze table table_name;
Clear table
Truncate table_name;
Delete table
Drop table_name;
Drop table if exists table_name;
Show all databases on the server
Show databases;
Show all tables of the current database
Show tables;
Display tables that meet the given conditions
Show tables like '% table_name % ';
Display the table structure of the specified table
Describe table_name;
Rename a table
Alter table Table1 rename Table2;
Create a table
Create Table table_name (
Field1 int (10) unsigned not null auto_increment,
Field2 varchar (10) Not null,
Primary Key (field1)
) Engine = MyISAM default charset = Latin1;
Change the attribute of a field and rename the field name.
Alter table table_name change old_name new_name varchar (80) not null;
Modify Field attributes without changing field names
Alter table table_name modify field_name varchar (100) not null;
Add a field at the beginning of the table
Alter table table_name add field_name varchar (10) Not null first;
Add a field at the end of the table
Alter table table_name add field_name varchar (10) Not NULL;
Add a field after a field
Alter table table_name add field_name varchar (10) Not null after field_x;
Deletes a field from a table.
Alter table table_name drop field_name;
Create an index
Create index index_name table_name (column_name );
Create an index using the first 10 characters of the name column:
Create index index_name on table_name (name (10 ));
Delete Index
Alter table table_name drop index index_name;
This article comes from the time drift bottle http://www.9usb.net, the original address: http://www.9usb.net/200811/mysql-yufa.html