Basic operation of MySQL database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.