SQL - Show Tables (Listing Tables)
MySQL Table Hunt 🕵️♂️
In the enchanted land of MySQL, unveil the magic to list all tables!
Syntax Incantation:
USE testDB;
SHOW TABLES;
Witness the tables appear, revealing their mystical names:
objectivecCopy code
Tables_in_testDB
CALENDAR
CUSTOMERS
COMPANIES
SALARY
Marvel at the spectacle of tables dancing before you!
SQL Server Table Quest 🚀
SQL Server, though subtle, reveals its tables using SELECT statements:
The SYS.TABLES Saga:
SELECT * FROM SYS.TABLES;
Objects emerge, showcasing their secrets:
arduinoCopy code
name object_id principal_id schema_id
CUSTOMER 4195065 NULL 1
ORDERS 68195293 NULL 1
COMPANIES 100195407 NULL 1
SALARY 2107154552 NULL 1
The INFORMATION_SCHEMA.TABLES Chronicle:
SELECT table_name, table_type FROM INFORMATION_SCHEMA.TABLES;
A tale unfolds, exposing the types of tables:
cssCopy code
table_name table_type
CUSTOMER BASE TABLE
ORDERS BASE TABLE
COMPANIES BASE TABLE
SALARY BASE TABLE
The SYSOBJECTS Odyssey:
SELECT name, id, xtype FROM sysobjects WHERE xtype = 'U';
Objects reveal their identities:
bashCopy code
name id xtype
CUSTOMER 4195065 U
ORDERS 68195293 U
COMPANIES 100195407 U
SALARY 2107154552 U
Oracle Table Oracle 🌌
In the oracle realm, unveil the tables using different SELECT rituals:
ALL Tables Oracle Quest:
SELECT owner, table_name FROM ALL_TABLES;
Tables emerge, each with its owner:
Copy code
owner table_name
SYS CUSTOMER
SYS ORDERS
HR COMPANIES
SCOTT SALARY
DBA Tables Oracle Chronicles:
SELECT owner, table_name FROM DBA_TABLES;
DBA tables step into the limelight:
Copy code
owner table_name
SYS CUSTOMER
SYS ORDERS
HR COMPANIES
SCOTT SALARY
USER Tables Oracle Exploration:
SELECT owner, table_name FROM USER_TABLES;
User-created tables take center stage:
Copy code
owner table_name
SCOTT SALARY
ALL Views Oracle Enigma:
SELECT view_name FROM ALL_VIEWS;
Views reveal their mysterious names:
view_name
EMPLOYEE_VIEW
DEPARTMENT_VIEW
SALARY_VIEW
Embark on the journey of SQL table discovery, whether in MySQL, SQL Server, or Oracle, and let the data adventures unfold! 🗺️🔍