Create database
Use MySQL to create a database and use the CREATE DATABASE statement to complete. The format is as follows:
CREATE database db_name;
Among them, db_name is the name of the database to be created. The name must be legal and cannot have the same name as other databases. There are some rules for naming legal databases (including other MySQL operation objects) as follows.
(1) The name can be any combination of letters, numbers, "-" or "$". It can start with any of the above characters, but cannot use a single number, which will cause it to be confused with the numerical value.
(2) The name length limit is: the names of databases, tables, columns, and indexes can consist of up to 64 characters, and aliases can be up to 256 characters.
(3) You cannot use MySQL keywords as database and table names.
The following creates a database named shili through the CREATE DATABASE statement, and displays all database names in the MySQL server through the SHOW DATABASES statement. The code is as follows:
mysql> create database shili ;
Query OK, 1 row affected ( 0.02 sec)
mysql> show databases;
+--------------------------+
| Database |
+------------ --------+
| information_schema |
| mysql |
| shili |
+--------------------------+
3 rows in set ( 0.00 sec)
The above is the content of the mysql tutorial: creating a database using the mysql command method. For more related articles, please pay attention to the PHP Chinese website (m.sbmmt.com)!