- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Querying average row length in MySQL?
You can use INFORMATION_SCHEMA.TABLES and AVG_ROW_LENGTH to query average row length in MySQL −
SELECT AVG_ROW_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ‘yourTableName’;
Let us first create a table −
mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.90 sec)
Insert records in the table using insert command −
mysql> insert into DemoTable(StudentName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(StudentName) values('Larry'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentName) values('Mike'); Query OK, 1 row affected (0.15 sec)
Display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 1 | John | | 2 | Larry | | 3 | Sam | | 4 | Mike | +-----------+-------------+ 4 rows in set (0.00 sec)
Query average row length in MySQL −
mysql> SELECT AVG_ROW_LENGTH FROM information_schema.tables WHERE TABLE_NAME = 'DemoTable';
This will produce the following output −
+----------------+ | AVG_ROW_LENGTH | +----------------+ | 4096 | +----------------+ 1 row in set (0.11 sec)
Advertisements