Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jrwarwick/32147fae1bd64655c4923f570c629464 to your computer and use it in GitHub Desktop.
Save jrwarwick/32147fae1bd64655c4923f570c629464 to your computer and use it in GitHub Desktop.
Generate Oracle QuickSQL from all visible tables
-- Quick, dirty, and incomplete. Look to dgielis/model_to_quicksql.sql for more power
select table_name||chr(10)||listagg(' '||column_name||' '
||case data_type
when 'VARCHAR2' then 'vc'||to_char(data_length)
when 'NUMBER' then 'num'
when 'INTEGER' then 'int'
when 'DATE' then 'date'
when 'INTEGER' then 'int'
END,chr(10)) within group (order by column_id) quicksql
from all_tab_cols
where owner like '%' -- Probably should specify at least one schema here!
group by table_name
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment