fork download
  1. CREATE TABLE EMPLOYEE (
  2. Fname varchar2(15) not null,
  3. Minit varchar2(1),
  4. Lname varchar2(15) not null,
  5. Ssn char(9),
  6. Bdate date,
  7. Address varchar2(30),
  8. Sex char,
  9. Salary number(10,2),
  10. Superssn char(9),
  11. Dno number(4),
  12. Email varchar2(50),
  13. primary key (Ssn),
  14. foreign key (Superssn) references EMPLOYEE(Ssn)
  15. );
  16.  
  17. CREATE TABLE DEPARTMENT (
  18. Dname varchar2(15) not null,
  19. Dnumber number(4),
  20. Mgrssn char(9) not null,
  21. Mgr_start_date date,
  22. primary key (Dnumber),
  23. unique (Dname),
  24. foreign key (Mgrssn) references EMPLOYEE(Ssn)
  25. );
  26.  
  27. alter table EMPLOYEE (
  28. foreign key (Dno) references DEPARTMENT(Dnumber)
  29. );
  30.  
  31. CREATE TABLE DEPT_LOCATIONS (
  32. Dnumber number(4),
  33. Dlocation varchar2(15),
  34. primary key (Dnumber,Dlocation),
  35. foreign key (Dnumber) references DEPARTMENT(Dnumber)
  36. );
  37.  
  38. CREATE TABLE PROJECT (
  39. Pname varchar2(15) not null,
  40. Pnumber number(4),
  41. Plocation varchar2(15),
  42. Dnum number(4) not null,
  43. primary key (Pnumber),
  44. unique (Pname),
  45. foreign key (Dnum) references DEPARTMENT(Dnumber)
  46. );
  47.  
  48. CREATE TABLE WORKS_ON (
  49. Essn char(9),
  50. Pno number(4),
  51. Hours number(4,1),
  52. primary key (Essn,Pno),
  53. foreign key (Essn) references EMPLOYEE(Ssn),
  54. foreign key (Pno) references PROJECT(Pnumber)
  55. );
  56.  
  57. CREATE TABLE DEPENDENT (
  58. Essn char(9),
  59. Dependent_name varchar2(15),
  60. Sex char,
  61. Bdate date,
  62. Relationship varchar2(8),
  63. primary key (Essn,Dependent_name),
  64. foreign key (Essn) references EMPLOYEE(Ssn)
  65. );
  66.  
  67. INSERT INTO EMPLOYEE VALUES ('James', 'E', 'Borg', '888665555', '10-NOV-27', 'Houston,TX', 'M', 55000, null, null, null);
  68. INSERT INTO EMPLOYEE VALUES ('Franklin', 'T', 'Wong', '333445555', '08-DEC-45', 'Houston,TX', 'M', 40000, '888665555', null, null);
  69. INSERT INTO EMPLOYEE VALUES ('Jennifer', 'S', 'Wallace', '987654321', '20-JUN-31', 'Bellaire,TX', 'F', 43000, '888665555', null, null);
  70.  
  71. INSERT INTO DEPARTMENT VALUES ('Research', 5, '333445555', '22-MAY-78');
  72. INSERT INTO DEPARTMENT VALUES ('Administration', 4, '987654321', '01-JAN-85');
  73. INSERT INTO DEPARTMENT VALUES ('Headquarters', 1, '888665555', '19-JUN-71');
  74.  
  75. UPDATE EMPLOYEE SET DNO = 5 WHERE Ssn = '333445555';
  76. UPDATE EMPLOYEE SET DNO = 4 WHERE Ssn = '987654321';
  77. UPDATE EMPLOYEE SET DNO = 1 WHERE Ssn = '888665555';
  78.  
  79. INSERT INTO EMPLOYEE VALUES ('John', 'B', 'Smith', '123456789', '09-Jan-55', 'Houston,TX', 'M', 30000, '333445555', 5, null);
  80. INSERT INTO EMPLOYEE VALUES ('Alicia', 'J', 'Zelaya', '999887777', '19-JUL-58', 'Spring,TX', 'F', 25000, '987654321', 4, null);
  81. INSERT INTO EMPLOYEE VALUES ('Ramesh', 'K', 'Narayan', '666884444', '15-SEP-52', 'Humble,TX', 'M', 38000, '333445555', 5, null);
  82. INSERT INTO EMPLOYEE VALUES ('Joyce', 'A', 'English', '453453453', '31-JUL-62', 'Houston, TX', 'F', 25000, '333445555', 5, null);
  83. INSERT INTO EMPLOYEE VALUES ('Ahmad', 'V', 'Jabbar', '987987987', '29-MAR-59', 'Houston,TX', 'M', 25000, '987654321', 4, null);
  84.  
  85. INSERT INTO PROJECT VALUES ('ProductX', 1, 'Bellaire', 5);
  86. INSERT INTO PROJECT VALUES ('ProductY', 2, 'Sugarland', 5);
  87. INSERT INTO PROJECT VALUES ('ProductZ', 3, 'Houston', 5);
  88. INSERT INTO PROJECT VALUES ('Computerization', 10, 'Stafford', 4);
  89. INSERT INTO PROJECT VALUES ('Reorganization', 20, 'Houston', 1);
  90. INSERT INTO PROJECT VALUES ('Newbenefits', 30, 'Stafford', 4);
  91.  
  92. INSERT INTO DEPT_LOCATIONS VALUES (1, 'Houston');
  93. INSERT INTO DEPT_LOCATIONS VALUES (4, 'Stafford');
  94. INSERT INTO DEPT_LOCATIONS VALUES (5, 'Bellaire');
  95. INSERT INTO DEPT_LOCATIONS VALUES (5, 'Sugarland');
  96. INSERT INTO DEPT_LOCATIONS VALUES (5, 'Houston');
  97.  
  98. INSERT INTO DEPENDENT VALUES ('333445555','Alice','F','05-APR-76','Daughter');
  99. INSERT INTO DEPENDENT VALUES ('333445555','Theodore','M','25-OCT-73','Son');
  100. INSERT INTO DEPENDENT VALUES ('333445555','Joy','F','03-MAY-48','Spouse');
  101. INSERT INTO DEPENDENT VALUES ('987654321','Abner','M','29-FEB-32','Spouse');
  102. INSERT INTO DEPENDENT VALUES ('123456789','Michael','M','01-JAN-78','Son');
  103. INSERT INTO DEPENDENT VALUES ('123456789','Alice','F', '31-DEC-78','Daughter');
  104. INSERT INTO DEPENDENT VALUES ('123456789','Elizabeth','F','05-MAY-57','Spouse');
  105.  
  106. INSERT INTO WORKS_ON VALUES ('123456789', 1, 32.5);
  107. INSERT INTO WORKS_ON VALUES ('123456789', 2, 7.5);
  108. INSERT INTO WORKS_ON VALUES ('666884444', 3, 40.0);
  109. INSERT INTO WORKS_ON VALUES ('453453453', 1, 20.0);
  110. INSERT INTO WORKS_ON VALUES ('453453453', 2, 20.0);
  111. INSERT INTO WORKS_ON VALUES ('333445555', 2, 10.0);
  112. INSERT INTO WORKS_ON VALUES ('333445555', 3, 10.0);
  113. INSERT INTO WORKS_ON VALUES ('333445555', 10, 10.0);
  114. INSERT INTO WORKS_ON VALUES ('333445555', 20, 10.0);
  115. INSERT INTO WORKS_ON VALUES ('999887777', 30, 30.0);
  116. INSERT INTO WORKS_ON VALUES ('999887777', 10, 10.0);
  117. INSERT INTO WORKS_ON VALUES ('987987987', 10, 35.0);
  118. INSERT INTO WORKS_ON VALUES ('987987987', 30, 5.0);
  119. INSERT INTO WORKS_ON VALUES ('987654321', 30, 20.0);
  120. INSERT INTO WORKS_ON VALUES ('987654321', 20, 15.0);
  121. INSERT INTO WORKS_ON VALUES ('888665555', 20, null);
  122.  
Success #stdin #stdout #stderr 0.01s 5476KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 27: near "(": syntax error