程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQLStudy之--MySQL工具mysqlshow

MySQLStudy之--MySQL工具mysqlshow

編輯:MySQL綜合教程

MySQLStudy之--MySQL工具mysqlshow


 

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)

 

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 | |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved