首頁 >資料庫 >mysql教程 >如何統計MySQL資料庫中表格的數量?

如何統計MySQL資料庫中表格的數量?

王林
王林轉載
2023-08-28 17:57:061596瀏覽

如何統計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刪除