
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to find current size (in memory) of table in MySQL?
To get the current size of a table, use the following that will display details about a table including the size −
show table status like ‘yourTableName’\G
Let us first create a table −
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> CustomerAge int, -> CustomerCountryName varchar(20) -> ); Query OK, 0 rows affected (0.75 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('John',24,'US'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('Carol',22,'UK'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----+--------------+-------------+---------------------+ | Id | CustomerName | CustomerAge | CustomerCountryName | +----+--------------+-------------+---------------------+ | 1 | John | 24 | US | | 2 | Carol | 22 | UK | +----+--------------+-------------+---------------------+ 2 rows in set (0.00 sec)
Here is the query to find current size (in memory) of a table −
mysql> show table status like 'DemoTable'\G
Output
*************************** 1. row *************************** Name: DemoTable Engine: InnoDB Version: 10 Row_format: Dynamic Rows: 0 Avg_row_length: 0 Data_length: 16384 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: NULL Create_time: 2019-06-10 16:35:55 Update_time: NULL Check_time: NULL Collation: utf8_unicode_ci Checksum: NULL Create_options: Comment: 1 row in set (0.01 sec)
- Related Articles
- How to modify the size of column in MySQL table?
- How to find total physical memory (RAM) size on Linux?
- How to get current activity available memory in android?
- How to get free size of internal/external memory in Android App?
- How to add current date to an existing MySQL table?
- How to use ALTER TABLE statement for changing the size of a column in MySQL?
- How can we insert current date automatically in a column of MySQL table?
- Getting size in memory of an object in PHP?
- How does free() know the size of memory to be deallocated?
- How to get free size of internal/external memory in Android App using Kotlin?
- How to find the number of columns in a MySQL table?
- Creating a Table in MySQL to set current date as default
- How can we insert current year automatically in a YEAR type column of MySQL table?
- How do I get the current AUTO_INCREMENT value for a table in MySQL?
- How to find all uppercase strings in a MySQL table?

Advertisements