Create a database, the name of the database is PHP
Example:
mysql> CREATE DATABASE PHP;
Query OK, 1 row affected (0.00 sec)
"Query OK" means the above command is executed successfully. "Query OK" is displayed after all DDL and DML (excluding SELECT) operations are executed successfully. , here it is understood that the execution is successful; "1 row affected" means that the operation only affects the records of one row in the database, and "0.00 sec" records the time when the operation was executed. If this database already exists, the system will display:
show refers to display Database refers to the database databases is the plural form of database, referring to all databases.
Example:
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| user |
+--------------------+
4 rows in set (0.00 sec)
Selected databaseBasic syntax:
##Category
Detailed explanation
Basic syntax
use library name;
# #Example
use PHP
Example description
Use database PHP
# #
Note: use refers to use; The library name is the name of the specific database that exists in the current database system;
Example:
mysql> use PHP;
Database changed
This will enter the PHP database. Of course, you can use the use statement to switch the database to be operated at any time. PHP has just been selected. Now let’s switch to the mysql database with mysql content and take a look:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
If "Database changed" appears, the switch is successful. Then, see what is in the mysql database (use the show statement the same as viewing the current database server database)
View the tables in the database
After entering the library, we can see what is in the library How many data tables.
Category
Detailed explanation
Basic syntax
show tables;
Example description
Show all tables under the current database
After using use to enter a database, you can use show tables
Example to view the tables of the current database:
The content in these tables is information data related to users, permissions, database status, settings, etc. related to the relational database server.
Delete database
Category
Detailed explanation
Basic syntax
DROP DATABASE library name;
Example
DROP DATABASE PHP;
Example description
Delete a database, the name of the database is liwenkai
Note: drop is in Chinese Translated to mean falling down, no longer needed database refers to the library The library name refers to the name of the library to be deleted
【Remember】Note: After the database is deleted, all data below will be deleted, so be careful and make appropriate backups before deleting. (If important data is not backed up, the actual data risk has nothing to do with this book.)
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning