🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 一、查询数据库 ### 1.展示系统中当前所有数据库:`show databases;` 例: ```sql mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | school | | school_01 | | shop | | sys | +--------------------+ 7 rows in set (0.00 sec) ``` ### 2.查询数据库的创建信息:`show create database db_name;` 例,查询数据库 school 和 mysql 的创建信息: ```sql mysql> show create database school; +----------+----------------------------------------------------------------------------------+ | Database | Create Database | +----------+----------------------------------------------------------------------------------+ | school | CREATE DATABASE `school` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ | +----------+----------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> show create database mysql; +----------+------------------------------------------------------------------+ | Database | Create Database | +----------+------------------------------------------------------------------+ | mysql | CREATE DATABASE `mysql` /*!40100 DEFAULT CHARACTER SET latin1 */ | +----------+------------------------------------------------------------------+ 1 row in set (0.00 sec) ``` ## 二、查询表 ## 三、查询信息 ### 1.查询给出的警告信息 `show warnings;` 例: ```sql mysql> create database if not exists test2; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> show warnings; +-------+------+------------------------------------------------+ | Level | Code | Message | +-------+------+------------------------------------------------+ | Note | 1007 | Can't create database 'test2'; database exists | +-------+------+------------------------------------------------+ 1 row in set (0.00 sec) ```