Wednesday 18 July 2018

How to find DB size and table info in MYSQL

How to find DB size and table info in MYSQL

1. To know the size of the databases
We can use this query “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”
This will display all the databases and its related size in MB. But we can change the range of size to be shown as per our wish. We have to just either increase the dividend value.
To know the size of only one db, we can use a where clause, such as WHERE table_schema = “db_name”
2. To know about the table information
 Type “SHOW TABLE STATUS”
 This will show the complete table status including the data length, index_length etc…
 3. To know about the user status in db
 Use this query “select * from mysql.`user`” . This will show the complete info of the user with this privileges etc…
4. To know the currently logged user
 we have three fucntions for this
  1. current_user()
  2. session_user()
  3. user()
The format of using this is select user();

5. To know the process information.
Execute SHOW PROCESSLIST

0 comments:

Post a Comment