Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Creating Tables and Inserting Data - using DDL
- --- Creating DEPARTMENT Table
- CREATE TABLE DEPT(
- Deptno NUMBER(3),
- Dname varchar2(14),
- Loc varchar2(13),
- CONSTRAINT DEPT_PK PRIMARY KEY (Deptno));
- --- To see the structure of table
- DESC DEPT;
- Descrept DEPT;
- ---Inserting Data into DEPARTMENT Table
- INSERT INTO Dept VALUES (10, 'ACCOUNTING', 'NEW YORK');
- INSERT INTO Dept VALUES (20, 'RESEARCH', 'DALLAS');
- INSERT INTO Dept VALUES (30, 'SALES', 'CHICAGO');
- INSERT INTO Dept VALUES (40, 'OPERATIONS', 'BOSTON');
- SELECT * FROM DEPT;
- -- Creating EMPLOYEE Table
- CREATE TABLE Emp(
- Empno NUMBER(4),
- Ename varchar2(10),
- Job varchar2(9),
- Mgr NUMBER(4),
- Hiredate DATE,
- Sal NUMBER(7,2),
- Comm NUMBER(7,2),
- Deptno NUMBER(2),
- CONSTRAINT Emp_FK FOREIGN KEY (Deptno)REFERENCES Dept(Deptno),
- CONSTRAINT Emp_PK PRIMARY KEY (Empno));
- --Inserting Data into DEPARTMENT Table
- INSERT INTO Emp VALUES (7369, 'Smith', 'Clerk', 7902, '17-DEC-80', 800, NULL, 20);
- INSERT INTO Emp VALUES (7499, 'Allen', 'Salesman', 7698, '20-FEB-81', 1600, 300, 30);
- INSERT INTO Emp VALUES (7521, 'Ward', 'Salesman', 7698, '22-FEB-81', 1250, 500, 30);
- INSERT INTO Emp VALUES (7566, 'Jones', 'Manager', 7839, '02-APR-81', 2975, NULL, 20);
- INSERT INTO Emp VALUES (7654, 'Martin', 'Salesman', 7698, '28-SEP-81', 1250, 1400, 30);
- INSERT INTO Emp VALUES (7698, 'Blake', 'Manager', 7839, '01-MAY-81', 2850, NULL, 30);
- INSERT INTO Emp VALUES (7782, 'Clark', 'Manager', 7839, '09-JUN-81', 2450, NULL,10);
- INSERT INTO Emp VALUES (7788, 'Scott', 'Analyst', 7566, '19-APR-87', 3000, NULL, 20);
- INSERT INTO Emp VALUES (7839, 'King', 'President', NULL,'17-NOV-81', 5000, NULL, 10);
- INSERT INTO Emp VALUES (7844, 'Turner', 'Salesman', 7698, '08-SEP-81', 1500, 0, 30);
- INSERT INTO Emp VALUES (7876, 'Adams', 'Clerk', 7788, '23-MAY-87', 1100, NULL, 20);
- INSERT INTO Emp VALUES (7900, 'James', 'Clerk', 7698, '03-DEC-81', 950, NULL, 30);
- INSERT INTO Emp VALUES (7902, 'Ford', 'Analyst', 7566, '03-DEC-81', 3000, NULL, 20);
- INSERT INTO Emp VALUES (7934, 'Miller', 'Clerk', 7782, '23-JAN-82', 1300, NULL, 10);
- ------------------------------------------------------------------------------------------------------
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement