🧚 Hey, listen! Try our modern & open source database GUI Download
March 21, 2023 By Beekeeper Studio Staff

Often database administrators and users want to know how many rows are there in each table or how big is the largest table in the database. Run the following SQL batch from your SQL query window to generates a list of all tables in your database together with the number of rows in each one. The list is sorted by table name but you can easily change the ORDER BY clause to sort it by the number of rows:

Syntax

USE db1
SELECT o.name as [Name], i.rowcnt as [Row Count]
FROM sysindexes i
INNER JOIN sysobjects o ON i.id = o.id
WHERE indid < 2 AND o.xtype = 'U'
ORDER BY Name

This query joins system tables to retrieve information about user tables (where xtype=’U’) and their row counts. You can modify the ORDER BY clause to sort by row count to quickly see your largest tables.

Beekeeper Studio Is A Free & Open Source Database GUI

Best SQL query & editor tool I have ever used. It provides everything I need to manage my database. - ⭐⭐⭐⭐⭐ Mit

Beekeeper Studio is fast, intuitive, and easy to use. Beekeeper supports loads of databases, and works great on Windows, Mac and Linux.

Beekeeper's Linux version is 100% full-featured, no cut corners, no feature compromises.

What Users Say About Beekeeper Studio

ā˜…ā˜…ā˜…ā˜…ā˜…
"Beekeeper Studio completely replaced my old SQL workflow. It's fast, intuitive, and makes database work enjoyable again."
— Alex K., Database Developer
ā˜…ā˜…ā˜…ā˜…ā˜…
"I've tried many database GUIs, but Beekeeper strikes the perfect balance between features and simplicity. It just works."
— Sarah M., Full Stack Engineer

Ready to Improve Your SQL Workflow?

download Download Free