- 选择数据库
mysql> use mysql;
Database changed
- 显示数据库列表
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| fish |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.08 sec)
- 显示数据表:
mysql> use fish;
Database changed
mysql> show tables;
+----------------+
| Tables_in_fish |
+----------------+
| runoob_tbl |
| test |
+----------------+
2 rows in set (0.04 sec)
- 显示数据表结构:
显示数据表的属性,属性类型,主键信息 ,是否为 NULL,默认值等其他信息。
Describe+表名
mysql> describe test;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(200) | NO | | NULL | |
| birthday | date | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
3 rows in set (0.06 sec)
Show Columns From+表名
mysql> show columns from test;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(200) | NO | | NULL | |
| birthday | date | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
3 rows in set (0.04 sec)
- 显示数据表的详细索引信息,包括PRIMARY KEY(主键)。
Show Index from + 表名
- 输出Mysql数据库管理系统的性能及统计信息
Show Table Status from + 数据库名 + LIKE 'test%';
- Grant查看用户权限:
查看当前用户(自己)权限:
show grants;
查看其他 MySQL 用户权限:
show grants for dba@localhost;