MySQL command line is a must-have knowledge to learn MySQL databases. The following describes 10 useful MySQL command lines. I hope it will help you learn MySQL command lines.
1. display the data table structure:
Mysql> DESCRIBE table name; (DESC table name)
2. Create a data table:
Mysql> USE Database Name; // enter the database
Mysql> create table Name (field name VARCHAR (20), field name CHAR (1 ));
3. delete a data table:
Mysql> drop table name;
4. rename a data table
Alter table t1 rename t2;
5. display the records in the table:
Mysql> SELECT * FROM table name;
6. insert records into the table:
Mysql> insert into table name VALUES ("hyq", "M ");
7. Update table data:
Mysql-> UPDATE table name SET field name 1 = 'a, field name 2 = 'B' WHERE field name 3 = 'C;
8. Clear records in the table:
Mysql> delete from table name;
9. load data into a data table in text mode:
Mysql> load data local infile "D:/mysql.txt" into table name;
10. display the table definition. You can also see the table constraints, such as foreign keys.
The above is an introduction to 10 commonly used MySQL command lines.