MySQL 数据库命令之 mysqlshow -- 显示 MySQL 数据库相关信息
生活随笔
收集整理的這篇文章主要介紹了
MySQL 数据库命令之 mysqlshow -- 显示 MySQL 数据库相关信息
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- 介紹
- 語法格式
- 常用選項
- 參考示例
- (一)顯示指定數(shù)據(jù)庫中的所有表的記錄數(shù)和列數(shù)
- (二)顯示指定數(shù)據(jù)庫中所有的數(shù)據(jù)表的額外信息
- (三)查看指定數(shù)據(jù)庫中的所有數(shù)據(jù)表
- (四)顯示所有的數(shù)據(jù)庫
- (五)統(tǒng)計數(shù)據(jù)庫表的列數(shù)和行數(shù)
- (六)顯示某個數(shù)據(jù)表的所有列信息
- (七)顯示表的鍵信息
介紹
mysqlshow 命令用于顯示 MySQL 服務器中的數(shù)據(jù)庫、表和列信息。
如果沒有指定數(shù)據(jù)庫,則顯示所有匹配的數(shù)據(jù)庫;如果沒有指定表,將顯示數(shù)據(jù)庫中所有匹配的表。如果沒有指定列,則顯示表中所有匹配的列。
語法格式
mysqlshow <選項> <參數(shù)>
參數(shù):指定要顯示的數(shù)據(jù)庫對象,可以是一個數(shù)據(jù)庫名,或者是數(shù)據(jù)庫名+表名,或者是數(shù)據(jù)庫名+表名+列名。
常用選項
| -h | MySQL服務器的IP地址或主機名 |
| -u | 連接MySQL服務器的用戶名 |
| -p | 連接MySQL服務器的密碼 |
| –count | 顯示每個數(shù)據(jù)表的行數(shù) |
| -k | 顯示數(shù)據(jù)庫表的索引,鍵 |
| -t | 顯示數(shù)據(jù)表的類型 |
| -i | 顯示數(shù)據(jù)表的額外信息 |
參考示例
(一)顯示指定數(shù)據(jù)庫中的所有表的記錄數(shù)和列數(shù)
[root@htlwk0001host ~]# mysqlshow -hlocalhost -uroot -p --count -t production Enter password: Database: production +-------------------------+------------+----------+------------+ | Tables | table_type | Columns | Total Rows | +-------------------------+------------+----------+------------+ | td_appraise_dimension | BASE TABLE | 4 | 5 |(二)顯示指定數(shù)據(jù)庫中所有的數(shù)據(jù)表的額外信息
[root@htlwk0001host ~]# mysqlshow -hlocalhost -uroot -p --count -t -i production Enter password:(三)查看指定數(shù)據(jù)庫中的所有數(shù)據(jù)表
[root@htlwk0001host ~]# mysqlshow -hlocalhost -uroot -p -t production # -t 選項會把表的類型也顯示出來 Enter password: Database: production +-------------------------+------------+ | Tables | table_type | +-------------------------+------------+ | td_area | BASE TABLE | | td_dictionary | BASE TABLE | [root@htlwk0001host ~]# mysqlshow -hlocalhost -uroot -p production Enter password: Database: production(四)顯示所有的數(shù)據(jù)庫
[root@mysql mysqlhelp]# mysqlshow -uroot -p Enter password: +--------------------+ | Databases | +--------------------+ | information_schema | | mysql | | oldboy | | performance_schema | | sys | | test | | xinyong | +--------------------+(五)統(tǒng)計數(shù)據(jù)庫表的列數(shù)和行數(shù)
(六)顯示某個數(shù)據(jù)表的所有列信息
[root@mysql mysqlhelp]# mysqlshow -uroot -p production tf_user Enter password: Database: production Table: tf_user +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+ | a | int(11) | | NO | PRI | | auto_increment | select,insert,update,references | | | b | varchar(30) | utf8_general_ci | YES | | | | select,insert,update,references | | +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+(七)顯示表的鍵信息
[root@mysql mysqlhelp]# mysqlshow -uroot -p -k production tf_user Enter password: Database: production Table: tf_user +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+ | a | int(11) | | NO | PRI | | auto_increment | select,insert,update,references | | | b | varchar(30) | utf8_general_ci | YES | | | | select,insert,update,references | | +-------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+---------+ +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | t | 0 | PRIMARY | 1 | a | A | 5 | | | | BTREE | | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+總結
以上是生活随笔為你收集整理的MySQL 数据库命令之 mysqlshow -- 显示 MySQL 数据库相关信息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 命令之 ll -- 列出当前
- 下一篇: Linux 启动/重启/停止 MySQL