To list all table names inside a specific database in SQL, query the system catalog views or INFORMATION_SCHEMA.TABLES for that database—most commonly in SQL Server (T-SQL) using sys.tables (or INFORMATION_SCHEMA.TABLES) and in MySQL using INFORMATION_SCHEMA.TABLES or SHOW TABLES.
- SQL Server (T-SQL): sys.tables and INFORMATION_SCHEMA.TABLES In SQL Server, run the query in the context of the target database (USE TargetDatabase;) or use three-part names (TargetDatabase.sys.tables / TargetDatabase.INFORMATION_SCHEMA.TABLES).
Using sys.tables (Recommended for SQL Server) SQL USE YourDatabaseName; GO
SELECT SCHEMA_NAME(t.schema_id) AS schema_name, t.name AS table_name FROM sys.tables AS t WHERE t.is_ms_shipped = 0 ORDER BY schema_name, table_name; sys.tables returns user-defined tables (excluding views), and filtering t.is_ms_shipped = 0 avoids system-shipped tables.
You can also query a specific database without switching context first:
SQL SELECT s.name AS schema_name, t.name AS table_name FROM YourDatabaseName.sys.tables AS t INNER JOIN YourDatabaseName.sys.schemas AS s ON t.schema_id = s.schema_id WHERE t.is_ms_shipped = 0 ORDER BY s.name, t.name; Using INFORMATION_SCHEMA.TABLES in SQL Server SQL SELECT TABLE_SCHEMA, TABLE_NAME FROM YourDatabaseName.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = ‘BASE TABLE’ ORDER BY TABLE_SCHEMA, TABLE_NAME; Filtering TABLE_TYPE = ‘BASE TABLE’ excludes views (‘VIEW’).
- MySQL: INFORMATION_SCHEMA.TABLES and SHOW TABLES In MySQL, filter INFORMATION_SCHEMA.TABLES by TABLE_SCHEMA to target a specific database:
SQL SELECT TABLE_NAME, ENGINE, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ‘your_database_name’ AND TABLE_TYPE = ‘BASE TABLE’ ORDER BY TABLE_NAME; You can also switch databases and list tables concisely:
SQL USE your_database_name; SHOW FULL TABLES WHERE Table_type = ‘BASE TABLE’; 3. PostgreSQL (Quick Cross-Reference) For completeness across relational engines, PostgreSQL lists base tables in the current database via information_schema.tables or pg_catalog.pg_tables:
SQL SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema NOT IN (‘pg_catalog’, ‘information_schema’) AND table_type = ‘BASE TABLE’ ORDER BY table_schema, table_name; 4. Operational Checklist Filter TABLE_TYPE = ‘BASE TABLE’ (or query sys.tables in SQL Server) when you only want physical tables and not views.
Include the schema name (schema_name / TABLE_SCHEMA) so tables with the same name in different schemas (such as dbo.orders vs. sales.orders) are clearly distinguished.
Avoid INFORMATION_SCHEMA for SQL Server metadata automation when sys.* views are richer—catalog views like sys.tables expose SQL Server-specific metadata directly and reliably.
