数据库的创建
Posted sxmzs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库的创建相关的知识,希望对你有一定的参考价值。
创建数据库
CREATE DATABASE 数据库名称;
mysql> CREATE DATABASE itcase;
Query OK, 1 row affected
查看数据库
SHOW DATABASE;
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| itcase |
| itsa |
| mysql |
| performance_schema |
| test |
+--------------------+
6 rows in set
查看某个已经创建的数据库信息
SHOW CREATE DATABASE 数据库名称
mysql> SHOW CREATE DATABASE itcase;
+----------+----------------------------------------------------------------+
| Database | Create Database |
+----------+----------------------------------------------------------------+
| itcase | CREATE DATABASE `itcase` /*!40100 DEFAULT CHARACTER SET gbk */ |
+----------+----------------------------------------------------------------+
1 row in set
修改数据库编码
ALTER DATABASE 数据库名称 DEFAULT CHARACTER SET 数据库编码;
数据库编码有gbk和utf8
mysql> ALTER DATABASE itcase DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected
查看修改后的数据库编码
mysql> SHOW CREATE DATABASE itcase;
+----------+-----------------------------------------------------------------+
| Database | Create Database |
+----------+-----------------------------------------------------------------+
| itcase | CREATE DATABASE `itcase` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-----------------------------------------------------------------+
1 row in set
删除数据库
DROP DATABASE 数据库名称;
mysql> DROP DATABASE itcase;
Query OK, 0 rows affected
查看数据库是否删除
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| itsa |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set
以上是关于数据库的创建的主要内容,如果未能解决你的问题,请参考以下文章