MySQL Database basic operations
First, overview:
We learned how to install a MySQL database, we will learn how to operate the MySQL database, this article is just some basic operational SQL statements, for reference only. If there is anything wrong place can leave a message. Thank you!
Second, the specific operation:
1.Use the "su" command to enter the root user.
2. Enter "Mysql-u root-p"and enter thepassword again to enter theMySQL database.
3. Create a database. "CREATE database name;"
4. View the database. "Show databases;" View table structure "show tables;"
5. Open the specified database. "Use database name;"
6. Delete the database. "Drop database name;"
7. Create a table. The CREATE TABLE table name (column name data type properties/constraints; ....... ..... ) ;》
8, primary key. "PRIMARY key definition primary key"
9. View the table. "Show tables;"
10. View the table structure. First to ' use database; ' , use the ' describe table name; ' 》
   11, modify the table structure. "alter table Table name add column Definition //add columns |drop Column name //Delete Column |add index index name (column name) //Add index |drop index Index name //Delete index |modify column definition //modifying a column definition |add primary key (column name) //Add primary key | drop primary key //Delete primary Key |rename New table name //Modify table name
12. Insert Data. insert into table name [(column name,... N)] VALUES (value,...) 》
13. View the data in the table. Select column name [as alias] [,... n]|*| expression->from table name [,... n]->[where conditional expression]->[order b Y-column name]->[group by column name]->[having conditional expression] "
14. Delete the data in the table. "Delete from table name [where conditional expression];"
15. Modify the data in the table. "Update table name set column name = value [where conditional expression];"
16, delete the table. "DROP table name;"
This article from "Lonely One Night" blog, declined reprint!
MySQL Operating manual