Advertisement
xbeji

Lab 1

Oct 22nd, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.21 KB | None | 0 0
  1.  
  2. --- Creating Tables and Inserting Data - using DDL
  3.  
  4. --- Creating DEPARTMENT Table
  5. CREATE TABLE DEPT(
  6. Deptno NUMBER(3),
  7. Dname varchar2(14),
  8. Loc varchar2(13),
  9. CONSTRAINT DEPT_PK PRIMARY KEY (Deptno));
  10.  
  11. --- To see the structure of table
  12.  
  13. DESC DEPT;
  14. Descrept DEPT;
  15.  
  16. ---Inserting Data into DEPARTMENT Table
  17. INSERT INTO Dept VALUES (10, 'ACCOUNTING', 'NEW YORK');
  18. INSERT INTO Dept VALUES (20, 'RESEARCH', 'DALLAS');
  19. INSERT INTO Dept VALUES (30, 'SALES', 'CHICAGO');
  20. INSERT INTO Dept VALUES (40, 'OPERATIONS', 'BOSTON');
  21.  
  22. SELECT * FROM DEPT;
  23.  
  24. -- Creating EMPLOYEE Table
  25. CREATE TABLE Emp(
  26. Empno NUMBER(4),
  27. Ename varchar2(10),
  28. Job varchar2(9),
  29. Mgr NUMBER(4),
  30. Hiredate DATE,
  31. Sal NUMBER(7,2),
  32. Comm NUMBER(7,2),
  33. Deptno NUMBER(2),
  34. CONSTRAINT Emp_FK FOREIGN KEY (Deptno)REFERENCES Dept(Deptno),
  35.  CONSTRAINT Emp_PK PRIMARY KEY (Empno));
  36.  
  37.  
  38. --Inserting Data into DEPARTMENT Table
  39. INSERT INTO Emp VALUES (7369, 'Smith', 'Clerk', 7902, '17-DEC-80', 800, NULL, 20);
  40.  
  41. INSERT INTO Emp VALUES (7499, 'Allen', 'Salesman', 7698, '20-FEB-81', 1600, 300, 30);
  42.  
  43. INSERT INTO Emp VALUES (7521, 'Ward', 'Salesman', 7698, '22-FEB-81', 1250, 500, 30);
  44.  
  45. INSERT INTO Emp VALUES (7566, 'Jones', 'Manager', 7839, '02-APR-81', 2975, NULL, 20);
  46.  
  47. INSERT INTO Emp VALUES (7654, 'Martin', 'Salesman', 7698, '28-SEP-81', 1250, 1400, 30);
  48.  
  49. INSERT INTO Emp VALUES (7698, 'Blake', 'Manager', 7839, '01-MAY-81', 2850, NULL, 30);  
  50.  
  51. INSERT INTO Emp VALUES (7782, 'Clark', 'Manager', 7839, '09-JUN-81', 2450, NULL,10);
  52.  
  53. INSERT INTO Emp VALUES (7788, 'Scott', 'Analyst', 7566, '19-APR-87', 3000, NULL, 20);
  54.  
  55. INSERT INTO Emp VALUES (7839, 'King', 'President', NULL,'17-NOV-81', 5000, NULL, 10);
  56.  
  57. INSERT INTO Emp VALUES (7844, 'Turner', 'Salesman', 7698, '08-SEP-81', 1500, 0, 30);
  58.  
  59. INSERT INTO Emp VALUES (7876, 'Adams', 'Clerk', 7788, '23-MAY-87', 1100, NULL, 20);
  60.  
  61. INSERT INTO Emp VALUES (7900, 'James', 'Clerk', 7698, '03-DEC-81', 950, NULL, 30);
  62.  
  63. INSERT INTO Emp VALUES (7902, 'Ford', 'Analyst', 7566, '03-DEC-81', 3000, NULL, 20);
  64.  
  65. INSERT INTO Emp VALUES (7934, 'Miller', 'Clerk', 7782, '23-JAN-82', 1300, NULL, 10);
  66. ------------------------------------------------------------------------------------------------------
  67.  
  68. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement