Skip to content

Commit cb1c698

Browse files
Create database_exploration.sql
1 parent e2d52a5 commit cb1c698

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scripts/database_exploration.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
===============================================================================
3+
Database Exploration
4+
===============================================================================
5+
Purpose:
6+
- To explore the structure of the database, including the list of tables and their schemas.
7+
- To inspect the columns and metadata for specific tables.
8+
9+
Table Used:
10+
- INFORMATION_SCHEMA.TABLES
11+
- INFORMATION_SCHEMA.COLUMNS
12+
===============================================================================
13+
*/
14+
15+
-- Retrieve a list of all tables in the database
16+
SELECT
17+
TABLE_CATALOG,
18+
TABLE_SCHEMA,
19+
TABLE_NAME,
20+
TABLE_TYPE
21+
FROM INFORMATION_SCHEMA.TABLES;
22+
23+
-- Retrieve all columns for a specific table (dim_customers)
24+
SELECT
25+
COLUMN_NAME,
26+
DATA_TYPE,
27+
IS_NULLABLE,
28+
CHARACTER_MAXIMUM_LENGTH
29+
FROM INFORMATION_SCHEMA.COLUMNS
30+
WHERE TABLE_NAME = 'dim_customers';

0 commit comments

Comments
 (0)