首页 > 数据库 > mysql教程 > 如何统计MySQL数据库中表的数量?

如何统计MySQL数据库中表的数量?

王林
发布: 2023-08-28 17:57:06
转载
1604 人浏览过

如何统计MySQL数据库中表的数量?

要计算表的总数,请使用 table_schema 的 count(*) 概念。首先,要检查我们的数据库“business”中有多少张表,我们需要使用“show”命令。

mysql> show tables;
登录后复制

以下是显示数据库“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)
登录后复制

上面我们数据库业务有132张表。

检查表的数量。

mysql> SELECT count(*) AS TOTALNUMBEROFTABLES
   -> FROM INFORMATION_SCHEMA.TABLES
   -> WHERE TABLE_SCHEMA = 'business';
登录后复制

以下输出给出了所有表的计数。

+---------------------+
| TOTALNUMBEROFTABLES |
+---------------------+
|                 132 |
+---------------------+
1 row in set (0.01 sec)
登录后复制

以上是如何统计MySQL数据库中表的数量?的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:tutorialspoint.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板