Created
December 25, 2021 10:23
-
-
Save ruslanmv/e89b28800d72b0ef18e9aa3159dafa6a to your computer and use it in GitHub Desktop.
Handy Tricks to explore DB/Athena
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Search for a columns in DB | |
SELECT COLUMN_NAME AS "ColumnName", | |
TABLE_NAME AS "TableName", | |
TABLE_SCHEMA | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE COLUMN_NAME LIKE 'cashfac_id' | |
ORDER BY TABLE_NAME, | |
COLUMN_NAME; | |
-- List all columns one table | |
SELECT COLUMN_NAME AS "ColumnName", | |
TABLE_NAME AS "TableName", | |
TABLE_SCHEMA | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE COLUMN_NAME LIKE 'cashfac_id' | |
ORDER BY TABLE_NAME, | |
COLUMN_NAME; | |
-- Explore Athena | |
-- Query to find all the columns in athena, which are having 'transactions' within its name */ | |
SELECT table_catalog as data_catalog, table_schema as tablename, table_name as columnname | |
FROM information_schema.tables | |
WHERE information_schema.tables.table_name like '%transactions%' | |
order by table_schema, table_name; | |
/* Note: AWS Athena specific syntax: | |
data catalog : table_catalog | |
table name : table_schema | |
column name : table_name | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment