First, view all databases
Mysql> Show databases;+--------------------+| Database |+--------------------+| information_schema | | mysql | | performance_schema | | WMS |+----------- ---------+
Among them, the first three are the database comes with three libraries.
II. basic syntax for creating a database
1. CREATE DATABASE database_name; database_name is the name of the database to be created, which cannot be the same name as a database that already exists.
For example:
mysql> CREATE DATABASE Db_test;
2. Once the database has been created, you can use the show CREATE database declaration to view the definition of the databases.
For example:
Mysql> Show CREATE Database db_test\g;*************************** 1. Row *************************** database:db_testcreate database:create Database ' db_test '/*!40100 DEFAULT CHARACTER SET latin1 */
3. Use the show DATABASES command to view all databases:
Mysql> Show databases;+--------------------+| Database |+--------------------+| information_schema | | db_test | | mysql | | performance_schema | | WMS |+--------------------+
Third, delete the database
1. Syntax
DROP DATABASE database_name; database_name is the name of the database to be deleted, and if the database does not exist, the delete error occurs.
2. Example
Mysql> Show databases;+--------------------+| Database |+--------------------+| information_schema | | db_test | | mysql | | performance_schema | | WMS |+--------------------+mysql> drop database db_test; Query OK, 0 rows affected (0.05 sec) mysql> show databases;+--------------------+| Database |+--------------------+| information_schema | | mysql | | performance_schema | | WMS |+----------- ---------+
3. Note: When using the drop Database command, be very cautious, when the command is executed, MySQL will not give any reminders to confirm the message, after the drop databases are deleted, all data tables and data stored in the database are deleted together, and cannot be recovered.
Iv. Select the current database
Grammar
Use database_name;
--------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------
If you have better suggestions, please email to my personal email address: [Email protected]
Copyright @: This article is my original, reproduced please indicate the source, thank you
Basic operation of MySQL database