MySQL FAQ: How to Check the Size of Tables in MySQL?



MySQL FAQ: How to Check the Size of Tables in MySQL?

MySQL FAQ: How to Check the Size of Tables in MySQL?

In this short sql tutorial we’ll show you how to check the size of a specific mysql table.

There are multiple queries you can employ to achieve your goal – the first one will return a result in kB, the second one – in MB, and the third one – in GB. Replace “wordpress” with your database name and “wp_users” with the name of the table you want to see the size of:

1) SELECT(data_length+index_length)/POWER(1024,1) AS Size_kB
FROM information_schema.tables
WHERE table_schema=’wordpress’ and table_name=’wp_users’;

2) SELECT(data_length+index_length)/POWER(1024,2) AS Size_MB
FROM information_schema.tables
WHERE table_schema=’wordpress’ and table_name=’wp_users’;

3) SELECT (data_length+index_length)/POWER(1024,3) AS Size_GB
FROM information_schema.tables
WHERE table_schema=’wordpress’ and table_name=’wp_users’;

Enjoy and tell about this tutorial to your friends!

Below you can find a couple of sql interview questions and answers – make sure to glance through them before attending your next sql interview!

Q: How to protect against SQL injection?
A: Don’t pass user input into a SQL query. You really don’t need to pass a mysql advanced tutorial to know this – it’s that simple!

Q: What is the file to adjust mysql server configuration?
A: The mysql my.cnf file on Linux or the mysql my.ini file on Windows is what you should look into. If needed, we’ll make a separate mysql tutorial for beginners on how it works. A mysql tutorial covering which storage engine – myisam vs innodb – to choose is available here: https://youtube.com/shorts/MpVWcYsJqn4

Q: Is there a sql full course or any mysql tutorial that would cover mysql storage engines in more detail in all complex aspects?
A: Not that we know of, but if needed, we’ll make a sql course talking about everything: sql basics, sql queries, sql vs nosql, sql for data analysis, etc.

Q: Is there a big data tutorial for those looking to work with big data on mysql server?
A: Yes, it’s available here: https://youtube.com/shorts/GurccdgcjL0

Q: I’ve heard that MyISAM performs row level locking?
A: No, that’s a common misconception.

Q: MyISAM vs InnoDB performance – which one is better and why?
A: InnoDB – all of the features that were available in MyISAM are now available in InnoDB.

Q: What types of SQL indexes exist?
A: There are B-Tree indexes, R-Tree indexes, hash indexes, covering indexes, clustered indexes, multicolumn or composite SQL indexes, and prefix indexes.

Q: What is the most popular type of a mysql index?
A: A B-tree sql index is the most popular type of a mysql index.

Music:
Trinidad by GroovyD https://soundcloud.com/musicforall-61338549
Creative Commons — Attribution 3.0 Unported — CC BY 3.0
Free Download / Stream: https://bit.ly/3M7e6hC
Music promoted by Audio Library: https://www.youtube.com/@audiolibrary_

#shorts #reels #database #mysql