MySQL we have installed is a database management tool. What is really valuable is data.
Relational database data exists in the form of tables, and N tables are aggregated into a database.
Now let's take a look at the basic operations of the database.
There are only three points: Create, delete, and view
Create a database
MySQL> Create DatabaseSchool; query OK,1Row affected (0.00Sec)
The create database statement is used to create a database, and the database name cannot be changed.
The school is the name of the database, and the semicolon ends.
If the execution is successful, query OK is displayed, and the execution time is also displayed.
When a database is available, the current database is usually viewed.
TIPS:When creating a database, it is best to add charset = utf8 at the end to specify the character set. In addition, character set or char set is also effective.
The equal sign is omitted or the default value is added before the statement.
Displays the database creation information.
MySQL > Show Create Database Test \ G *************************** 1 . Row *************************** Database : Test Create Database : Create Database 'Test'/* ! 40100 default Character Set utf8 */ 1 Row In Set ( 0.00 Sec)
The show create database statement is used to view the statements used to create a database.
The character set is the default character set.
View Database
MySQL > Show databases; + -- ------------------ + | Database | + -- ------------------ + | Information_schema | | MySQL | | Performance_schema | | School | | Test| + -- ------------------ + 5 Rows In Set ( 0.00 Sec)
In this way, the created database is displayed, where school is the one just created
The remaining items exist by default. Do not change them.
Test is used for testing and can be deleted.
Delete Database
MySQL> Drop DatabaseSchool; query OK,0Rows affected (0.00Sec)
It's easy to delete. Just run the drop database Command.
Next, you can use show databases to view the effect.
Note that do not forget the semicolon after the statement
In practice, we operate more than databases, but tables in databases.
So the content here is very simple.