Count SQL for Data tables/fields in MySQL database

Source: Internet
Author: User

1. Query the number of fields in a table:

SELECT COUNT (*) from INFORMATION_SCHEMA. COLUMNS
WHERE table_schema = ' database name '
and table_name = ' table name ';

2. Query How many tables are in a database:

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

3. Query the number of fields in a database:

SELECT COUNT (column_name) from INFORMATION_SCHEMA. COLUMNS WHERE table_schema = ' database name ';

4. Query all the tables in a database and all fields, field types and comments, and other information:

SELECT table_name, COLUMN_NAME, Data_type, column_comment from INFORMATION_SCHEMA. COLUMNS
WHERE table_schema = ' database name ';

Count SQL for Data tables/fields in MySQL database

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.