MySQL Study之--MySQL工具mysqlshow,--mysqlmysqlshow
MySQL Study之--MySQL工具mysqlshow mmysqlshow客戶可用來很快地尋找存在哪些資料庫,資料庫中的表,表中的列或索 mysqlshow為一些SQL顯示語句提供了一個命令列介面。相同的資訊可以通過直接使用那些語句獲得。例如,你可以從mysql客戶程式發出它們。 象這樣調用mysqlshow:
shell> mysqlshow[選項] [db_name [tbl_name [col_name]]
- 如果沒有給出資料庫,顯示所有匹配的資料庫。
- 如果沒有給出表,顯示資料庫中所有匹配的表。
- 如果沒有給出列,顯示表中所有匹配的列和列類型。
|
案例:
[root@mysrv mysql]# mysqlshow --helpmysqlshow 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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 onlywhat'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 tableare 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 clientThe 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 latin1count FALSEcompress FALSEdebug-check FALSEdebug-info FALSEhost (No default value)status FALSEkeys FALSEport 3306show-table-type FALSEsocket /tmp/mysql.sockssl FALSEssl-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 FALSEuser (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 | |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+---------+
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。