Home > Database > Mysql Tutorial > How to count the number of tables in a MySQL database?

How to count the number of tables in a MySQL database?

王林
Release: 2023-08-28 17:57:06
forward
1583 people have browsed it

How to count the number of tables in a MySQL database?

To count the total number of tables, use the count(*) concept of table_schema. First, to check how many tables we have in our database "business" we need to use the "show" command.

mysql> show tables;
Copy after login

The following is the output showing all tables in the database "business".

+--------------------------+
| Tables_in_business       |
+--------------------------+
| addcheckconstraintdemo   |
| addcolumntable           |
| addconstraintdemo        |
| addnotnulldemo           |
| alphademo                |
| autoincrement            |
| autoincrementtable       |
| backticksymbol           |
| bookindexes              |
| chardemo                 |
| checkdemo                |
| clonestudent             |
| columnexistdemo          |
| columnvaluenulldemo      |
| commaseperatedemo        |
| currentdatetime          |
| dateadddemo              |
| deletedemo               |
| deleterecord             |
| demo                     |
| demo1                    |
| demoascii                |
| demoauto                 |
| demobcrypt               |
| demoemptyandnull         |
| demoint                  |
| demoonreplace            |
| demoschema               |
| demowhere                |
| distcountdemo            |
| distinctdemo             |
| distinctdemo1            |
| duplicatebookindexes     |
| duplicatefound           |
| employeerecords          |
| employeetable            |
| escapedeom               |
| existsrowdemo            |
| findandreplacedemo       |
| firsttable               |
| foreigntable             |
| foreigntabledemo         |
| functionindexdemo        |
| functiontriggersdemo     |
| groupconcatenatedemo     |
| groupdemo                |
| groupdemo1               |
| groupt_concatdemo        |
| ifelsedemo               |
| imagedemo                |
| incasesensdemo           |
| indexingdemo             |
| int1demo                 |
| intdemo                  |
| keydemo                  |
| latandlangdemo           |
| limitoffsetdemo          |
| milliseconddemo          |
| modifycolumnnamedemo     |
| modifydatatype           |
| moneydemo                |
| moviecollection          |
| multipleindexdemo        |
| multiplerecordwithvalues |
| myisamtoinnodbdemo       |
| mytable                  |
| mytable1                 |
| newstudent               |
| nextpreviousdemo         |
| nonasciidemo             |
| nthrecorddemo            |
| nulldemo                 |
| nullwithselect           |
| numbercolumndemo         |
| ondemo                   |
| originaltable            |
| pasthistory              |
| presenthistory           |
| primarytable             |
| primarytable1            |
| primarytabledemo         |
| qutesdemo                |
| rowcountdemo             |
| rownumberdemo            |
| rowstranspose            |
| rowstransposedemo        |
| saveintotextfile         |
| saveoutputintext         |
| secondtable              |
| sequencedemo             |
| singlequotesdemo         |
| smallintdemo             |
| sortingvarchardemo       |
| sourcetable              |
| spacecolumn              |
| student                  |
| studentrecordwithmyisam  |
| studenttable             |
| table1                   |
| table2                   |
| tabledemo                |
| tbldemotrail             |
| tblf                     |
| tblfirst                 |
| tblfunctiontrigger       |
| tblifdemo                |
| tblp                     |
| tblselectdemo            |
| tblstudent               |
| tbluni                   |
| tblupdatelimit           |
| textdemo                 |
| texturl                  |
| timestampdemo            |
| trailingandleadingdemo   |
| transcationdemo          |
| triggedemo               |
| trigger1                 |
| trigger2demo             |
| trimdemo                 |
| trimdemo2                |
| uniqueconstdemo          |
| uniquedemo               |
| unsigneddemo             |
| updtable                 |
| usernameandpassworddemo  |
| varchardemo              |
| varchardemo1             |
| varchardemo2             |
| varcharurl               |
| whereconditon            |
| xmldemo                  |
+--------------------------+
132 rows in set (0.01 sec)
Copy after login

There are 132 tables in our database business above.

Check the number of tables.

mysql> SELECT count(*) AS TOTALNUMBEROFTABLES
   -> FROM INFORMATION_SCHEMA.TABLES
   -> WHERE TABLE_SCHEMA = 'business';
Copy after login

The following output gives the count for all tables.

+---------------------+
| TOTALNUMBEROFTABLES |
+---------------------+
|                 132 |
+---------------------+
1 row in set (0.01 sec)
Copy after login

The above is the detailed content of How to count the number of tables in a MySQL database?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template