20.4. Using mysqlshow to Obtain Metadata


20.4. Using mysqlshow to Obtain Metadata

The mysqlshow client program produces information about the structure of your databases and tables. It provides a command-line interface to various forms of the SHOW statement that list the names of your databases, tables within a database, or information about table columns or indexes. The mysqlshow command has this syntax:

 mysqlshow [options] [db_name [table_name [column_name]]] 

The options part of the mysqlshow command may include any of the standard connection parameter options, such as --host or --user. You'll need to supply these options if the default connection parameters aren't appropriate. mysqlshow also understands options specific to its own operation. Invoke mysqlshow with the --help option to see a complete list of its options.

The action performed by mysqlshow depends on the number of non-option arguments you provide:

  • With no arguments, mysqlshow displays a result similar to that of SHOW DATABASES:

     shell> mysqlshow +--------------------+ |     Databases      | +--------------------+ | information_schema | | menagerie          | | mysql              | | test               | | world              | +--------------------+ 

  • With a single argument, mysqlshow interprets it as a database name and displays a result similar to that of SHOW TABLES for the database:

     shell> mysqlshow world Database: world +-----------------+ |     Tables      | +-----------------+ | City            | | Country         | | CountryLanguage | +-----------------+ 

  • With two arguments, mysqlshow interprets them as a database and table name and displays a result similar to that of SHOW FULL COLUMNS for the table. With three arguments, the output is the same as for two arguments except that mysqlshow takes the third argument as a column name and displays SHOW FULL COLUMNS output only for that column. The following commands are examples of this invocation syntax. (The output is not shown because it is too wide to fit the page.)

     shell> mysqlshow world City shell> mysqlshow world City CountryCode 

When mysqlshow is used to display table structure, the --keys option may be given to display index structure as well. This information is similar to the output of SHOW INDEX for the table.

If the final argument on the command line contains special characters, mysqlshow interprets the argument as a pattern and displays only the names that match the pattern. The special characters are '%' or '*' to match any sequence of characters, and '_' or '?' to match any single character. For example, the following command shows only those databases with a name that begins with 'w':

 shell> mysqlshow "w%" 

The pattern characters might be treated as special by your command interpreter. An argument that contains any such characters should be quoted, as shown in the preceding example. Alternatively, use a character that your command interpreter doesn't treat specially. For example, '*' can be used without quoting on Windows and '%' without quoting on Unix.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net