Skip to content

Instantly share code, notes, and snippets.

@loiclefevre
Created April 8, 2022 10:31
Embed
What would you like to do?
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