- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to know the exact number of table and columns in a MySQL database?
To get the exact number if table and columns in a MySQL database, use the DISTINCT inside COUNT().
Let’s say we have a database ‘sample’ and we need to work on it to get the exact number of table and columns.
To achieve it, the query is as follows −
mysql> SELECT COUNT(DISTINCT TABLE_NAME) AS TotalTable,Count(Column_Name) AS TOTALColumn -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE TABLE_SCHEMA = 'sample';
The following is the output displaying the count of table and columns in the database ‘sample’ −
+------------+-------------+ | TotalTable | TOTALColumn | +------------+-------------+ | 123 | 287 | +------------+-------------+ 1 row in set (0.02 sec)
- How to find the number of columns in a MySQL table?
- Get the number of columns in a MySQL table?
- How to alter the database engine of a MySQL database table?
- Exact count of all rows in MySQL database?
- Count the number of columns in a MySQL table with Java
- How to select the table with the greatest number of columns in MySQL?
- How to know the exact time to load a page using Selenium WebDriver?
- How to get the number of columns of a table using JDBC?
- How to get the datatype of MySQL table columns?
- How to update two columns in a MySQL database?
- Counting the number of non-null or nonzero columns in a MySQL table?
- How to count the number of tables in a MySQL database?
- How to count number of columns in a table with jQuery
- How to check table status of the tables in a particular MySQL database?
- How to take backup of a single table in a MySQL database?