Database Management for MySql learning, mysql learning database
To learn mysql Data step by step, you must first manage mysql Data.
1. Create a database
Command Format: create database [if not exists] database_name.
In actual use, [] is not required. Note that exists is followed by s. For example, on my mysql console, enter the following command:
Create database if not exists usp;
If the feedback is correct, a statement is directly returned as follows:
Query OK, 1 row affected.
2. display the databases in mysql
Command Format: show databases
In actual use, pay attention to the s following databases.
Show datbases;
The interface will return:
-----------------------------------
| Database |
-----------------------------------
| Information_schema |
| Mysql |
| Perfermance_schema |
| Test |
| Usp |
----------------------------------
3. Select a working database
Command Format: USE databasename;
This command changes the current scope.
4. delete a database
Command Format: drop database if exists datbasename;
When using this command, pay attention to the exists command.
Note that the command drop is not delete.
Drop databse if exists usp;
The interface returns: query OK.