- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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)
Advertisements