MySQL从小白到总裁完整教程目录:https://blog.csdn.net/weixin_67859959/article/details/129334507?spm=1001.2014.3001.5502
语法格式:
show create database 数据库名称;
案列:查看testing数据库信息
- mysql> show create database testing;
- +----------+-----------------------------------------------------------------+
- | Database | Create Database |
- +----------+-----------------------------------------------------------------+
- | testing | CREATE DATABASE `testing` /*!40100 DEFAULT CHARACTER SET gbk */ |
- +----------+-----------------------------------------------------------------+
- 1 row in set (0.00 sec)
练习:查看当前有多少个数据库
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | bd_ecshop |
- | mysql |
- | performance_schema |
- | test |
- | testing |
- +--------------------+
- 6 rows in set (0.01 sec)
一共有六个数据库
查看一下数据库名称为MySQL的数据库的字符集是什么
- mysql> show create database mysql;
- +----------+------------------------------------------------------------------+
- | Database | Create Database |
- +----------+------------------------------------------------------------------+
- | mysql | CREATE DATABASE `mysql` /*!40100 DEFAULT CHARACTER SET latin1 */ |
- +----------+------------------------------------------------------------------+
- 1 row in set (0.00 sec)
字符集是Latin1
比如说我把数据库名写错,它会怎么显示
- mysql> show create database mysql222;
- ERROR 1049 (42000): Unknown database 'mysql222'
练习:创建一个数据库名称为czwbkl,字符集为utf8 数据库的全名是橙子味冰可乐的缩写,以后经常会用到,哈哈哈
- mysql> create database czwbkl charset utf8;
- Query OK, 1 row affected (0.00 sec)
-
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | bd_ecshop |
- | czwbkl |
- | mysql |
- | performance_schema |
- | test |
- | testing |
- +--------------------+
- 7 rows in set (0.00 sec)
-
- mysql> show create database czwbkl;
- +----------+-----------------------------------------------------------------+
- | Database | Create Database |
- +----------+-----------------------------------------------------------------+
- | czwbkl | CREATE DATABASE `czwbkl` /*!40100 DEFAULT CHARACTER SET utf8 */ |
- +----------+-----------------------------------------------------------------+
- 1 row in set (0.00 sec)