The various SQL statements are formally introduced from this section. This section describes SQL at the database level and related operations, viewing, building, and deleting.
Show the existing database by showing
Syntax: Show DATABASES [like Wild]
If you use the like wild section, the wild string can be a string that uses the SQL "%" and "_" wildcard characters.
Features: Show databases lists the databases on the MySQL server host.
You can try the following examples to observe the output, for example:
Mysql>show databases;
+----------+
| Database |
+----------+
| A |
| MySQL |
| MyTest |
| Test |
| Test1 |
+----------+
mysql>show databases like ' my% ';
+----------------+
| Database (my%) |
+----------------+
| MySQL |
| MyTest |
+----------------+
You can also get a list of existing databases using the Mysqlshow program.
Creating a database with Create Dabase
Syntax: CREATE DATABASE db_name
Function: Create database creates a data base with the given name.
An error occurred if the database already exists.
The database in MySQL is implemented as a directory containing the files in the corresponding database tables. Because the database was initially created without any tables, the CREATE DATABASE statement simply creates a directory below the MySQL data directory.
For example:
Mysql>create database Myfirst;
Then use show databases to observe the effect.