Oracle Cheat Sheet

1. get version of oracle database

SELECT * FROM "V$VERSION"

2. get timestamp of last commit

SELECT ORA_ROWSCN FROM schema.table

3. get name of the database

select name, db_unique_name,log_mode from v$database

4. get create table statement

select dbms_metadata.get_ddl( 'TABLE', 'name_of_table', 'schema' ) FROM dual

5. select rowid (base64 encoded pseudocolumn)

SELECT rowid FROM schema.table WHERE rownum <= 100

6. Query all_tables

SELECT *FROM all_tables WHERE  num_rows > 1

7. Get information about a table:

SELECT* FROM ALL_TABLES WHERE TABLE_NAME = 'your_table'

8. Query all_views

select * FROM all_views

9. Pagination using offset ... fetch (do a google search for seek pagination method which is supposed to be faster)

SELECT* FROM ALL_ALL_TABLES OFFSET M ROWS FETCH NEXT N ROWS ONLY

10. To know when a row was last updated you can try using the ORA_ROWSCN pseudo-column together with SCN_TO_TIMESTAMP. Read the fine-print.

This entry was posted in Computers, programming, Software and tagged . Bookmark the permalink.

Leave a comment