1. Display the list of databases.
show databases;
2. Display the data table in the library:
Use MySQL;
Show tables;
3, display the structure of the data table:
describe table name;
4, build the library:
Create database name;
5, build the table:
Use library name;
CREATE TABLE table name (field settings list);
6. Deleting the library and deleting the table:
drop database name;
drop table name;
7. Empty the records in the table:
Delete from table name;
8. Display the records in the table:
SELECT * FROM table name
9, the change shows:
ALTER TABLE table_name rename Table_new_name;
10. Copy the table
1?? Copy table structure and data to a new table
CREATE Table New Table SELECT * from old table
This method will copy all the contents of oldtable, of course, we can use the delete from newtable; To delete. But one of the worst things about this approach is that the new table has no properties such as primary key, Extra (auto_increment), and so on. Need to use "alter", add, and easy to mistake.
2?? Copy table structure to new table only
CREATE table new table SELECT * from old table WHERE 1=2 or CREATE table new tables like old table
3?? Copy data from old table to new table (assuming two table structure)
INSERT into new table SELECT * from old table
MySQL command line common commands