![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Total number of fields in all tables in database?
To get total number of fields in all tables in database, you can use information_schema.columns along with aggregate function count(*).
We are using ‘sample’ database which consists of a lot of tables with fields. Following is the query to get total number of fields in all tables in database:
mysql> SELECT COUNT(*) AS TOTAL_NUMBER_OF_FIELDS -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE TABLE_SCHEMA = 'sample';
This will produce the following output
+------------------------+ | TOTAL_NUMBER_OF_FIELDS | +------------------------+ | 796 | +------------------------+ 1 row in set (0.04 sec)
Now, let us check another database ‘test’. Following is the query to get total number of fields in all tables in database:
mysql> SELECT COUNT(*) AS TOTAL_NUMBER_OF_FIELDS -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE TABLE_SCHEMA= 'test';
This will produce the following output
+------------------------+ | TOTAL_NUMBER_OF_FIELDS | +------------------------+ | 1108 | +------------------------+ 1 row in set (0.03 sec)
Advertisements