The MySQL metabase uses Information_schema.tables to query the database and data table information

Source: Internet
Author: User
Tags metabase


Overview for databases such as MySQL and Infobright, the tables in the INFORMATION_SCHEMA database are read-only and cannot be updated, deleted, inserted, or triggered because they are actually just a view, not a base table, and have no associated files. Information_schema.tablesThe metadata information for the data table is stored, and the fields that are commonly used are described below:
    • Table_schema: Record database name ;
    • TABLE_NAME: Record data table name ;
    • Engine: Storage engines ;
    • Table_rows: A rough line estimate of the table;
    • Data_length: the size of the record table (in bytes);
    • Index_length: The size of the index of the record table;
    • Row_format: You can see if the data table has been compressed ;

Here are a few common uses; Information_schema.tables information;
 
   
  
  1. use information_schema;
  2. show create table tables;

 
   
  
  1. desc tables;

Querying all of the database information
 
   
  
  1. select distinct TABLE_SCHEMA from tables ;

Querying the database and data table information displays all table information below the MySQL database: (in common use)
 
   
  
  1. use mysql;
  2. show tables;

Get database and data table information through Information_schema.table:
 
   
  
  1. use information_schema;
  2. select TABLE_SCHEMA ,table_name from tables where table_schema like ‘mysql‘;

Data table size and index sizeExample 1:Mysql.time_zone Related tables
Gets the size of the Time_zone related table:
 
   
  
  1. select (sum(DATA_LENGTH) + sum(INDEX_LENGTH)) as size from tables where table_schema=‘mysql‘ and table_name like ‘time_%‘;


Example 2: Get the size of the specified database;
 
   
  
  1. select (sum(DATA_LENGTH) + sum(INDEX_LENGTH)) as size from tables where table_schema=‘mysql‘;

Determine if the MyISAM data table is compressed
 
   
  
  1. select distinct row_format,engine from information_schema.tables where engine=‘myisam‘;

    • Fixed: Indicates compressed;
    • Dynamic: Indicates uncompressed;

 
   
  
  1. select row_format,engine,table_name from information_schema.tables where engine=‘myisam‘;
get database and data table information directly from Linux instructions:
 
   
  
  1. mysql -uroot -pxxxx -D information_schema -e "select TABLE_SCHEMA ,table_name from tables where table_schema like ‘hsm_syslog_%‘"

Parameter description:

    • -D: Indicates the name of the database;
    • -E: Indicates the command to be executed:;




























From for notes (Wiz)

The MySQL metabase uses Information_schema.tables to query the database and data table information

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.