Skip to content

Instantly share code, notes, and snippets.

@loiclefevre
Created April 8, 2022 10:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loiclefevre/1ae2e9f496e0156277feeff1b6e03242 to your computer and use it in GitHub Desktop.
Save loiclefevre/1ae2e9f496e0156277feeff1b6e03242 to your computer and use it in GitHub Desktop.
Listagg function
-- Getting list of columns per table
SELECT table_name,
LISTAGG(column_name, ', '
ON OVERFLOW TRUNCATE
'... with more column(s) '
WITH COUNT
) WITHIN GROUP
(ORDER BY column_id) AS columns
FROM all_tab_columns
GROUP BY table_name;
TABLE_NAME COLUMNS -- If too many columns...
-------------- --------------------------------------------------
CUSTOMERS CUSTOMER_ID, FIRST_NAME, LAST_NAME, SECRET_NAME
GREEK_TEMPLE […], HEIGHT, WEIGHT, ... with more column(s) (8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment