ホームページ > データベース > mysql チュートリアル > MySQLStudy之--MySQL工具mysqlshow_MySQL

MySQLStudy之--MySQL工具mysqlshow_MySQL

WBOY
リリース: 2016-06-01 12:59:35
オリジナル
1246 人が閲覧しました

 

MySQL Study之--MySQL工具mysqlshow

mmysqlshow客户可用来很快地查找存在哪些数据库,数据库中的表,表中的列或索

mysqlshow为一些SQL显示语句提供了一个命令行界面。相同的信息可以通过直接使用那些语句获得。例如,你可以从mysql客户程序发出它们。

象这样调用mysqlshow:
shell> mysqlshow[选项] [db_name [tbl_name [col_name]]
  • 如果没有给出数据库,显示所有匹配的数据库。
  • 如果没有给出表,显示数据库中所有匹配的表。
  • 如果没有给出列,显示表中所有匹配的列和列类型。

 

案例:

 

[root@mysrv mysql]# mysqlshow --help
mysqlshow  Ver 9.10 Distrib 5.1.66, for redhat-linux-gnu (x86_64)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Shows the structure of a MySQL database (databases, tables, and columns).

Usage: mysqlshow [OPTIONS] [database [table [column]]]

If last argument contains a shell or SQL wildcard (*,?,% or _) then only
what's matched by the wildcard is shown.
If no database is given then all matching databases are shown.
If no table is given, then all matching tables in database are shown.
If no column is given, then all matching columns and column types in table
are shown.

Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 
The following groups are read: mysqlshow client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
  -c, --character-sets-dir=name 
                      Directory for character set files.
  --default-character-set=name 
                      Set the default character set.
  --count             Show number of rows per table (may be slow for non-MyISAM
                      tables).
  -C, --compress      Use compression in server/client protocol.
  -#, --debug[=name]  Output debug log. Often this is 'd:t:o,filename'.
  --debug-check       Check memory and open file usage at exit.
  --debug-info        Print some debug info at exit.
  -?, --help          Display this help and exit.
  -h, --host=name     Connect to host.
  -i, --status        Shows a lot of extra information about each table.
  -k, --keys          Show keys for table.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given, it's solicited on the tty.
  -P, --port=#        Port number to use for connection or 0 for default to, in
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                      /etc/services, built-in default (3306).
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -t, --show-table-type 
                      Show table type column.
  -S, --socket=name   The socket file to use for connection.
  --ssl               Enable SSL for connection (automatically enabled with
                      other flags).Disable with --skip-ssl.
  --ssl-ca=name       CA file in PEM format (check OpenSSL docs, implies
                      --ssl).
  --ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).
  --ssl-cert=name     X509 cert in PEM format (implies --ssl).
  --ssl-cipher=name   SSL cipher to use (implies --ssl).
  --ssl-key=name      X509 key in PEM format (implies --ssl).
  --ssl-verify-server-cert 
                      Verify server's "Common Name" in its cert against
                      hostname used when connecting. This option is disabled by
                      default.
  -u, --user=name     User for login if not current user.
  -v, --verbose       More verbose output; you can use this multiple times to
                      get even more verbose output.
  -V, --version       Output version information and exit.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- -----------------------------
character-sets-dir                (No default value)
default-character-set             latin1
count                             FALSE
compress                          FALSE
debug-check                       FALSE
debug-info                        FALSE
host                              (No default value)
status                            FALSE
keys                              FALSE
port                              3306
show-table-type                   FALSE
socket                            /tmp/mysql.sock
ssl                               FALSE
ssl-ca                            (No default value)
ssl-capath                        (No default value)
ssl-cert                          (No default value)
ssl-cipher                        (No default value)
ssl-key                           (No default value)
ssl-verify-server-cert            FALSE
user                              (No default value)<strong>
</strong>
ログイン後にコピー

 

1、不指定查看的database

[root@mysrv mysql]# mysqlshow -uroot -poracle
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| mysqlslap |
| performance_schema |
| prod |
| sakila |
| test |
+--------------------+
2、指定查看的database

[root@mysrv mysql]# mysqlshow -uroot -poracle mysql
Database: mysql
+---------------------------+
| Tables |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
[root@mysrv mysql]# mysqlshow -uroot -poracle prod
Database: prod
+--------+
| Tables |
+--------+
| t1 |
| t2 |
| t3 |
| t4 |
+--------+

3、查看指定

[root@mysrv mysql]# mysqlshow -uroot -poracle prod t1
Database: prod Table: t1
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| id | int(11) | | NO | PRI | 0 | | select,insert,update,references | |
| name | varchar(10) | latin1_swedish_ci | YES | | | | select,insert,update,references | |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート