-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_database_exploration.sql
More file actions
30 lines (27 loc) · 893 Bytes
/
01_database_exploration.sql
File metadata and controls
30 lines (27 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
===============================================================================
Database Exploration
===============================================================================
Purpose:
- To explore the structure of the database, including the list of tables and their schemas.
- To inspect the columns and metadata for specific tables.
Table Used:
- INFORMATION_SCHEMA.TABLES
- INFORMATION_SCHEMA.COLUMNS
===============================================================================
*/
-- Retrieve a list of all tables in the database
SELECT
TABLE_CATALOG,
TABLE_SCHEMA,
TABLE_NAME,
TABLE_TYPE
FROM INFORMATION_SCHEMA.TABLES;
-- Retrieve all columns for a specific table (dim_customers)
SELECT
COLUMN_NAME,
DATA_TYPE,
IS_NULLABLE,
CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'dim_customers';