mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cainiao |
| mysql |
2、切换到某一个数据库
mysql> use cainiao
Database changed
3、查询该数据库中有哪些表
mysql> show tables;
+-------------------+
| Tables_in_cainiao |
+-------------------+
| tb_user |
| test1 |
| test2 |
| user |
+-------------------+
4 rows in set (0.00 sec)
4、查看某个表的表结构
mysql> describe user;
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| user_id | int(11) | NO | PRI | NULL | auto_increment |
| user_name | varchar(20) | NO | | NULL | |
| user_password | char(32) | NO | | NULL | |
| user_right | varchar(50) | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
5、查看表的索引信息
如果表有索引,可以使用show index from <表名>来进行查看。
关于怎样通过命令行来获取MySQL中数据库和表的信息,本文就介绍这么多,希望对大家有所帮助,谢谢!