Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Latest commit

 

History

History
43 lines (35 loc) · 1.81 KB

README.md

File metadata and controls

43 lines (35 loc) · 1.81 KB
  • Python script to setup new SQL file

    for i in range (1,17):
         print("/* "+str(i)+"\n\n*/\n\n")
  • Create a new user in SQL *Plus

  • SQL command to list all tables in Oracle

    SELECT 
        table_name
    FROM
        user_tables;
  • Drop all tables in Oracle DB (scheme)
    copy and paste the output

    SELECT 'DROP TABLE "' || TABLE_NAME || '" CASCADE CONSTRAINTS;' FROM user_tables;
    
    
  • Comments in SQL

    -- single line commment
    /* multi line comment */
  • Display names of all constraints for a table in Oracle SQL

    SELECT *
      FROM user_constraints
     WHERE table_name = '<your table name>'
       AND constraint_name = '<your constraint name>';
  • Never put AS in FROM clause in Oracle SQL

  • EXCEPT clause doesn't work, instead use MINUS instead

  • use ROLLBACK TO <savpoint name> to go to a savepoint
    NOTE: savepoints are created for the current session only

  • UNIQUE doesn't work in Oracle SQL so use count(*) method like in book