Common commands
1. Displays the list of databases in the current database server:
MySQL> SHOW DATABASES;
2. Establish the database:
MySQL>CREATEdatabase name;
3. Set up the data sheet:
MySQL> use library name; MySQL>CREATETABLEVARCHAR(1CHAR);
4. Delete the database:
MySQL>DROPdatabase name;
5. Delete Data sheet:
MySQL>DROP table name;
6. Empty the records in the table:
MySQL>DELETE from table name; (This command represents the emptying of the table data)
TRUNCATE table name; (This command represents the emptying of the table data and initializing the table)
7. Insert a record into the table:
MySQL>INSERTintoVALUES ("HyQ", "M");
8. Update the data in the table:
MySQL-UPDATESET field name 1='a', field name 2=' b'WHERE field Name 3='C';
9. Load data into the data table in text mode:
MySQL>LOAD DATA LOCAL INFILE "D:/ into table table name;
10. Import the. sql File command:
MySQL> use database name; MySQL> SOURCE d:/mysql.sql;
11, the command line to modify the root password:
MySQL>UPDATE MySQL. User SET Password=password (' new password 'WHEREUser= ' Root ' ; MySQL>privileges;
The above are all regular, and below are some of the available
In-table plus fields
Alter TableTable nameAddField nameint not NULL default 'Default Value'Comment'Notes'After field name; Alter TableProjectAddTypetinyint not NULL default 2Comment'default is 2,2 for normal business, 3 for business card'
In-table modified fields
Alter Table column varchar (" home Address ";
Add index
Alter Table Add Index Lname_fname (Lname,fname); (federated index) Alter Table Add index fname (fname); (Single-column index)
MySQL Common commands