Query How many tables are in a database in MySQL

Source: Internet
Author: User

SELECT COUNT (*) TABLES, table_schema from INFORMATION_SCHEMA. TABLES WHERE table_schema = ' database ' GROUP by Table_schema;

This is the first time contact INFORMATION_SCHEMA this database,

The INFORMATION_SCHEMA database is a MySQL-band that provides a way to access database metadata. What is meta data? Metadata is data about the data, such as the database name or table name, the data type of the column, or access permissions. Some of the other terms used to express this information include the data dictionary and the system catalog. In MySQL, think of Information_schema as a database, specifically an information database. It holds information about all the other databases maintained by the MySQL server. such as database name, database table, table column data type and access permissions. In Information_schema, there are a few read-only tables. They are actually views, not basic tables, so you will not be able to see any files associated with them.

Information_schema database Table Description:

Schemata Table: Provides information for all databases in the current MySQL instance. This table is the result of show databases.

Tables Table: Provides information about the tables in the database, including views. Describes in detail which schema, table type, table engine, creation time, and so on, a table belongs to. This table is the result of show tables from SchemaName.

Columns table: Provides the column information in the table. Describes in detail all the columns of a table and the information for each column. This table is the result of show columns from Schemaname.tablename.

Statistics Table: Provides information about the index of a table. This table is the result of show index from Schemaname.tablename.

User_privileges (User Rights) Table: gives information about the full range of permissions. This information is derived from the Mysql.user authorization form. Non-standard tables.

Schema_privileges (Program permissions) Table: Provides information about schema (database) permissions. This information is from the Mysql.db authorization form. Non-standard tables.

Table_privileges (table permissions) Table: Gives information about table permissions. This information is derived from the Mysql.tables_priv authorization form. Non-standard tables.

Column_privileges (column permissions) Table: Gives information about column permissions. This information is derived from the Mysql.columns_priv authorization form. Non-standard tables.

Character_sets (character Set) Table: Provides information about the available character sets for MySQL instances. This table is the show CHARACTER set result set.

Collations table: Provides cross-reference information about each character set.

Collation_character_set_applicability table: Indicates the character set that can be used for proofreading. These columns are equivalent to the first two display fields of show collation.

Table_constraints table: A table describing the existence of constraints. And the constraint type of the table.

Key_column_usage table: Describes the key columns that have constraints.

Routines Table: Provides information about storing subroutines (stored programs and functions). At this point, the routines table does not contain a custom function (UDF). A column named "Mysql.proc name" indicates the corresponding INFORMATION_SCHEMA. The Mysql.proc table column for the routines table.

Views Table: Gives information about the view in the database. You need to have show views permission, otherwise you cannot view the view information.

Triggers table: Provides information about the triggering program. You must have super privileges to view the table

Query How many tables are in a database in MySQL

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.