-
Notifications
You must be signed in to change notification settings - Fork 14
02 SQL ‐ Show Tables
To display a list of tables in a SQL database, you can use a database-specific command. The command may vary depending on the database management system you are using. Here are examples for some popular database systems:
-
MySQL and MariaDB:
To list all tables in the current database, you can use the
SHOW TABLES
command or query theinformation_schema
database:Using
SHOW TABLES
:SHOW TABLES;
Using
information_schema
:SELECT table_name FROM information_schema.tables WHERE table_schema = 'your_database_name';
Replace
'your_database_name'
with the name of your database. -
PostgreSQL:
To list all tables in the current schema, you can use the following query:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
This query lists tables in the "public" schema, which is the default schema in PostgreSQL. Replace 'public' with the name of your schema if you are using a different one.
-
SQL Server:
To list all tables in the current database, you can use a query like this:
SELECT table_name = t.name FROM sys.tables t INNER JOIN sys.schemas s ON t.schema_id = s.schema_id;
This query retrieves tables and their schema names.
Please ensure that you have appropriate permissions to view the tables in the database. The specific syntax and commands may vary depending on the database management system you are using, so consult your database system's documentation for details specific to your environment.