MySQL 5.0 Reference Manual  /  ...  /  mysql_tableinfo — Generate Database Metadata

4.6.16 mysql_tableinfo — Generate Database Metadata

mysql_tableinfo creates tables and populates them with database metadata. It uses SHOW DATABASES, SHOW TABLES, SHOW TABLE STATUS, SHOW COLUMNS, and SHOW INDEX to obtain the metadata.

In MySQL 5.0 and up, the INFORMATION_SCHEMA database contains the same kind of information in the SCHEMATA, TABLES, COLUMNS, and STATISTICS tables. See Chapter 19, INFORMATION_SCHEMA Tables.

Invoke mysql_tableinfo like this:

shell> mysql_tableinfo [options] db_name [db_like [tbl_like]]

The db_name argument indicates which database mysql_tableinfo should use as the location for the metadata tables. The database will be created if it does not exist. The tables will be named db, tbl (or tbl_status), col, and idx.

If the db_like or tbl_like arguments are given, they are used as patterns and metadata is generated only for databases or tables that match the patterns. These arguments default to % if not given.


mysql_tableinfo info
mysql_tableinfo info world
mysql_tableinfo info mydb tmp%

Each of the commands stores information into tables in the info database. The first stores information for all databases and tables. The second stores information for all tables in the world database. The third stores information for tables in the mydb database that have names matching the pattern tmp%.

mysql_tableinfo supports the following options:

Table 4.14 mysql_tableinfo Options

--clearBefore populating each metadata table, drop it if it exists
--clear-onlySimilar to --clear, but exits after dropping the metadata tables to be populated.
--colGenerate column metadata into the col table
--helpDisplay help message and exit
--hostConnect to MySQL server on given host
--idxGenerate index metadata into the idx table
--passwordPassword to use when connecting to server -- not optional
--portTCP/IP port number to use for connection
--prefixAdd prefix_str at the beginning of each metadata table name
--quietBe silent except for errors
--socketFor connections to localhost, the Unix socket file to use
--tbl-statusUse SHOW TABLE STATUS instead of SHOW TABLES
--userThe mysql_tableinfo user name to use when connecting to server

User Comments
Sign Up Login You must be logged in to post a comment.