Home >Database >Mysql Tutorial >How to display, delete, modify and select databases in MySQL
1. Delete database
mysql> drop database stu;
If the deleted database does not exist, an error will be reported. The solution is to judge before deleting and delete it if it exists
mysql> drop database if exists stu; Query OK, 0 rows affected (0.00 sec)
2. Display the statement to create the database
Syntax: show create database database name
mysql> show create database yudb;
---------- --------------------- -----------------------------------------------
| Database | Create Database
---------- -------------------------------- -------------------------------
| yudb | CREATE DATABASE `yudb` /*!40100 DEFAULT CHARACTER SET gbk */
------------------------------------------ -------------------------------
3. Modify database character encoding
Syntax: alter database database name charset=character encoding;
mysql> alter database yudb charset=utf8; Query OK, 1 row affected (0.00 sec)
4. Select database
Syntax: use database name
mysql> use yudb; Database changed
The above is the detailed content of How to display, delete, modify and select databases in MySQL. For more information, please follow other related articles on the PHP Chinese website!