Advertisement
fkeles

OCI_COST_DATA_MV.sql

May 23rd, 2023
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.62 KB | Source Code | 0 0
  1. -- create a temp table
  2. CREATE TABLE OCI_COST_DATA_MV_TMP AS
  3. SELECT * FROM OCI_COST_DATA;
  4.  
  5. -- add primary key
  6. ALTER TABLE OCI_COST_DATA_MV_TMP ADD CONSTRAINT REFERENCE_NUMBER_TMP_PK PRIMARY KEY(REFERENCE_NUMBER);
  7.  
  8. -- Build the materialized view using the existing temp table
  9. CREATE MATERIALIZED VIEW OCI_COST_DATA_MV_TMP
  10. ON PREBUILT TABLE
  11. REFRESH COMPLETE
  12. ON DEMAND
  13. AS
  14. SELECT * FROM OCI_COST_DATA;
  15.  
  16. -- Create actual data table
  17. CREATE TABLE OCI_COST_DATA_MV AS
  18. SELECT * FROM OCI_COST_DATA_MV_TMP;
  19.  
  20. -- Create actual PK
  21. ALTER TABLE OCI_COST_DATA_MV ADD CONSTRAINT REFERENCE_NUMBER_PK PRIMARY KEY(REFERENCE_NUMBER);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement