Home > Database > Mysql Tutorial > MySQL database operations: create, view, use, delete

MySQL database operations: create, view, use, delete

巴扎黑
Release: 2017-04-26 17:41:49
Original
1706 people have browsed it

1. Create a database

Use the standard database creation statement to create a MySQL database.

The syntax format is as follows:

CREATE DATABASE  数据库名;
Copy after login

When creating a database, there are several rules for naming the database:

1. It cannot have the same name as other databases, otherwise an error will be reported;

2. Is the name deliberately composed of any letters, Arabic numerals, underscores and "$"? You can start with any of the above characters, but you cannot use numbers alone, otherwise it will be confused with the numerical value;

3. The name can be up to 64 characters, and the alias can be up to 256 characters;

4. MySQL keywords cannot be used as database names and table names.


2. View the database

After successfully creating the database, you can use the view command to view the All database information.

The syntax format is as follows:

SHOW DATABASES;
Copy after login

Note: It is databases, followed by S, because there may be multiple tables, adding S means plural in English.

3. Select the database

Although you have created a database, the system does not know which database you want to operate. At this time, you can choose first database.

The syntax format is as follows:

USE 数据库名;
Copy after login

4. Delete the database

It is easier to understand if you delete it, you can delete it if you don’t need it anymore.

The syntax format is as follows:

DROP DATABASE 数据库名;
Copy after login

Note: Once the database is deleted, all contents in the database will be deleted and cannot be restored, so be careful before deleting.

The above is the detailed content of MySQL database operations: create, view, use, delete. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template