SHARE
TWEET

Untitled

a guest Sep 8th, 2017 129 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ACCEPT TABOWNER DEFAULT 'DEMO' prompt 'Choose DEPT/EMP table owner [DEMO] '
  2.  
  3. REM
  4. REM ====================== DEPT ======================
  5. REM
  6.  
  7. CREATE TABLE &TABOWNER.dept
  8. (
  9.   DEPTNO  NUMBER(2),
  10.   DNAME   VARCHAR2(14),
  11.   LOC     VARCHAR2(13)
  12. )
  13. LOGGING
  14. NOCACHE
  15. NOPARALLEL;
  16.  
  17. INSERT INTO &TABOWNER.dept VALUES (10, 'ACCOUNTING', 'NEW YORK');
  18. INSERT INTO &TABOWNER.dept VALUES (20, 'RESEARCH', 'DALLAS');
  19. INSERT INTO &TABOWNER.dept VALUES (30, 'SALES', 'CHICAGO');
  20. INSERT INTO &TABOWNER.dept VALUES (40, 'OPERATIONS', 'BOSTON');
  21.  
  22. REM
  23. REM ====================== EMP ======================
  24. REM
  25.  
  26. CREATE TABLE &TABOWNER.emp
  27. (
  28.   empno     NUMBER(4) PRIMARY KEY,
  29.   ename     VARCHAR2(10),
  30.   job       VARCHAR2(9),
  31.   mgr       NUMBER(4) REFERENCES emp,
  32.   hiredate  DATE,
  33.   sal       NUMBER(7, 2),
  34.   comm      NUMBER(7, 2),
  35.   deptno    NUMBER(2) REFERENCES dept
  36. )
  37. LOGGING
  38. NOCACHE
  39. NOPARALLEL;
  40.  
  41. CREATE INDEX &TABOWNER.emp_mgr_idx ON &TABOWNER.emp(mgr);
  42. CREATE INDEX &TABOWNER.emp_deptno_idx ON &TABOWNER.emp(deptno);
  43.  
  44. INSERT INTO &TABOWNER.emp VALUES (7839, 'KING', 'PRESIDENT', NULL, TO_DATE('171181', 'DDMMRR'), 5000, NULL, 10);
  45. INSERT INTO &TABOWNER.emp VALUES (7698, 'BLAKE', 'MANAGER', 7839, TO_DATE('010581', 'DDMMRR'), 2850, NULL, 30);
  46. INSERT INTO &TABOWNER.emp VALUES (7782, 'CLARK', 'MANAGER', 7839, TO_DATE('090681', 'DDMMRR'), 2450, NULL, 10);
  47. INSERT INTO &TABOWNER.emp VALUES (7566, 'JONES', 'MANAGER', 7839, TO_DATE('020481', 'DDMMRR'), 2975, NULL, 20);
  48. INSERT INTO &TABOWNER.emp VALUES (7499, 'ALLEN', 'SALESMAN', 7698, TO_DATE('200281', 'DDMMRR'), 1600, 300, 30);
  49. INSERT INTO &TABOWNER.emp VALUES (7521, 'WARD', 'SALESMAN', 7698, TO_DATE('220281', 'DDMMRR'), 1250, 500, 30);
  50. INSERT INTO &TABOWNER.emp VALUES (7654, 'MARTIN', 'SALESMAN', 7698, TO_DATE('280981', 'DDMMRR'), 1250, 1400, 30);
  51. INSERT INTO &TABOWNER.emp VALUES (7902, 'FORD', 'ANALYST', 7566, TO_DATE('031281', 'DDMMRR'), 3000, NULL, 20);
  52. INSERT INTO &TABOWNER.emp VALUES (7369, 'SMITH', 'CLERK', 7902, TO_DATE(TO_DATE('171280', 'DDMMRR'), 800, NULL, 20);
  53. INSERT INTO &TABOWNER.emp VALUES (7788, 'SCOTT', 'ANALYST', 7566, TO_DATE('091282', 'DDMMRR'), 3000, NULL, 20);
  54. INSERT INTO &TABOWNER.emp VALUES (7844, 'TURNER', 'SALESMAN', 7698, TO_DATE('080981', 'DDMMRR'), 1500, 0, 30);
  55. INSERT INTO &TABOWNER.emp VALUES (7876, 'ADAMS', 'CLERK', 7788, TO_DATE('120183', 'DDMMRR'), 1100, NULL, 20);
  56. INSERT INTO &TABOWNER.emp VALUES (7900, 'JAMES', 'CLERK', 7698, TO_DATE('031281', 'DDMMRR'), 950, NULL, 30);
  57. INSERT INTO &TABOWNER.emp VALUES (7934, 'MILLER', 'CLERK', 7782, TO_DATE('230182', 'DDMMRR'), 1300, NULL, 10);
  58.  
  59. COMMIT;
  60.  
  61. REM
  62. REM ====================== PUBLIC SYNONYMs ======================
  63. REM
  64.  
  65. PROMPT WARNING, two PUBLIC synonyms are going TO be created.
  66. PROMPT ^C IF you want TO break AT this point OR press ENTER TO continue.
  67. PAUSE
  68.  
  69. CREATE PUBLIC SYNONYM dept FOR &TABOWNER.dept;
  70.  
  71. CREATE PUBLIC SYNONYM emp FOR &TABOWNER.emp;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top