You are on page 1of 2

--- Copyright (c) Oracle Corporation 1988, 2000. All Rights Reserved. --- NAME -demobld.

sql --- DESCRIPTION -This script creates the SQL*Plus demonstration tables in the -current schema. It should be STARTed by each user wishing to -access the tables. To remove the tables use the demodrop.sql -script. -Comments not -- USAGE processed by SQL -From within SQL*Plus, enter: -START demobld.sql --SET TERMOUT ON --PROMPT Building demonstration tables. --SET TERMOUT OFF DROP DROP DROP DROP DROP TABLE TABLE TABLE TABLE TABLE EMP; DEPT; BONUS; SALGRADE; DUMMY;

Please wait.

Remove any existing tables with the same names as the ones we are going to use to avoid errors

CREATE TABLE EMP Create a new table called EMP EMPNO NUMBER(4) NOT NULL, EMPNO is PK in EMP, 4 digits ENAME VARCHAR2(10), ENAME is 10 characters name of employee JOB VARCHAR2(9), JOB is 9 characters MGR NUMBER(4), MGR is FK points to another employee as manager HIREDATE is date format date started work HIREDATE DATE, SAL NUMBER(7, 2), SAL is 7 digits, 2 after decimal point (currency) COMM NUMBER(7, 2), COMM is 7 digits, 2 after decimal point (currency) DEPTNO NUMBER(2)); DEPTNO is 2 digits

INSERT INTO EMP VALUES Insert data into the EMP table (7369, Insert 7369 as the employee number for SMITH in table EMP 'SMITH', Insert SMITH as name of employee 7369 'CLERK', Insert CLERK as the job title for SMITH 7902, Insert 7902 as the EMP NO for SMITHs manager (FORD) TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), Insert 17 Dec 1980 as the hire date for SMITH 800, Insert the value 800 as the salary for SMITH in table EMP NULL, Insert the value NULL as the value for commission for SMITH in table EMP 20); Insert the value 20 (RESEARCH) as the DEPTNO in table EMP

INSERT INTO EMP VALUES Insert data into the EMP table (7499, Insert 7499 as the employee number for ALLEN in table EMP 'ALLEN', Insert ALLEN as name of employee 7499 'SALESMAN', Insert CLERK as the job title for SMITH 7698, Insert 7698 as the EMP NO for ALLENs manager TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), Insert 20 Feb 1981 as the hire date for ALLEN 1600, Insert the value 1600 as the salary for ALLEN in table EMP 300, Insert the value 300 as the value for commission for ALLEN in table EMP 30); Insert the value 30 (SALES) as the DEPTNO in table EMP

You might also like