DB Size for all schema on server
สำหรับผู้ดูแลระบนั้น การหา Database size เป็นเรื่องที่ต้องการ ดังนั้นจึงแนะ Sql command ที่ใช้หา Database Size ดังนี้
SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
บวกค่าของ the data_length + index_length is equal to the total table size.
- data_length – store the real data.
- index_length – store the table index.
Result:
+--------------------------------+----------------------+ | Data Base Name | Data Base Size in MB | +--------------------------------+----------------------+ | digital_publishing_development | 0.43750000 | | digital_publishing_test | 0.39062500 | | information_schema | 0.00878906 | | mediawrap3_development | 8.28125000 | | mediawrap3_production | 1099.12500000 | | mysql | 0.61379814 | | performance_schema | 0.00000000 | +--------------------------------+----------------------+ 7 rows in set (7.55 sec)
Find DB Size specific Schema
การหา database size เฉพาะตัวที่ต้องการ สามารถทำได้โดยการระบุ Database name แทนใน YOUR_DB_NAME
SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES where TABLE_SCHEMA like '%YOUR_DB_NAME%' GROUP BY table_schema ;
จะแสดงเฉพาะ database ที่เราต้องการ
Result:
+----------------+----------------------+ | Data Base Name | Data Base Size in MB | +----------------+----------------------+ | dooexpert | 23.93848324 | +----------------+----------------------+ 1 row in set (2.82 sec)
Show database/table command
ในกรณีที่ต้องการดูว่ามี database/schema อะไรบ้าง ใน MySql server นี้ ใช้ command
show database;
ในกรณีที่ต้องการดูว่ามี table อะไรให้ทำดังนี้ แทนค่า Database_Name
mysql> use Database_Name; mysql> show tables;
Advertisement