Skip to content

Instantly share code, notes, and snippets.

@62mkv
Last active February 4, 2020 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 62mkv/1dcdfde18e22f30cdd239a2dd62fee74 to your computer and use it in GitHub Desktop.
Save 62mkv/1dcdfde18e22f30cdd239a2dd62fee74 to your computer and use it in GitHub Desktop.
Oracle cheatsheet
  • Show table DDL:
    select dbms_metadata.get_ddl('TABLE', '<your table name>') from dual

  • List all of the (available) tables: select * from user_tables

  • List of all the tables with a given column: select * from all_tab_columns where COLUMN_NAME like '%ERR_SEQ%'

  • List all views with a name like X: select * from all_views where view_name like '%COMM%'

  • Using substitution variables in SQL Developer:

define start_date = '2020-01-01'
define end_date = '2020-02-01'

select * from table 
where date_field between to_date('&start_date', 'YYYY-MM-DD') and to_date('&end_date', 'YYYY-MM-DD');
  • List all columns with comments like X: select * from user_col_comments where upper(comments) like upper('%close%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment