Rumah > Artikel > pangkalan data > Bagaimana untuk mendapatkan saiz jadual dalam pangkalan data MySQL?
Untuk mendapatkan saiz jadual dalam pangkalan data MySQL, anda boleh menggunakan "information_schema.tables".
Ini ialah sintaks untuk mendapatkan semua saiz jadual.
SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` FROM information_schema.TABLES WHERE TABLE_SCHEMA = "yourDatabaseName" ORDER BY (DATA_LENGTH + INDEX_LENGTH) ASC;
Mari kita gunakan sintaks di atas untuk mendapatkan saiz jadual.
mysql> SELECT TABLE_NAME AS `ALLTABLESNAME`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `TABLESIZEIN(MB)` -> FROM information_schema.TABLES WHERE TABLE_SCHEMA = "business" -> ORDER BY (DATA_LENGTH + INDEX_LENGTH) ASC;
Contoh output.
+------------------------------------------------------------------+-----------------+ | ALLTABLESNAME | TABLESIZEIN(MB) | +------------------------------------------------------------------+-----------------+ | studentrecordwithmyisam | 0 | | querydatedemo | 1 | | rownumberdemo | 0 | | secondtable | 0 | | spacecolumn | 2 | | table1 | 0 | | tbldemotrail | 2 | | tblstudent | 0 | | timestamptodatedemo | 1 | | uniqueconstraintdemo | 0 | | usernameandpassworddemo | 2 | | addingunique | 5 | | bookindexes | 0 | | tblf | 0 | | uniquedemo | 2 | | multipleindexdemo | 0 | | uniquedemo1 | 0 | | foreigntable | 5 | | tabledemo2 | 0 | | foreigntabledemo | 2 | | studentenrollment | 0 | | tabledemo3 | 0 | | duplicatebookindexes | 0 | | clonestudent | 2 | | student | 0 | +------------------------------------------------------------------+-----------------+ 26 rows in set (10.29 sec)
Atas ialah kandungan terperinci Bagaimana untuk mendapatkan saiz jadual dalam pangkalan data MySQL?. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!