You are on page 1of 65

1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 1/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 2/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 3/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 4/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 5/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 6/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 7/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 8/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 9/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 10/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 11/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 12/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 13/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 14/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 15/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 16/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 17/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 18/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 19/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 20/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 21/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 22/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 23/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 24/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 25/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 26/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 27/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 28/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 29/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 30/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 31/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 32/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 33/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 34/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 35/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 36/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 37/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 38/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 39/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 40/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 41/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 42/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 43/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 44/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 45/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 46/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 47/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 48/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 49/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 50/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 51/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 52/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 53/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 54/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 55/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 56/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 57/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 58/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 59/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 60/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 61/65
1/9/2018 FULL Script Human Resources for Oracle Database

COMMENT ON COLUMN employees.department_id


IS 'Department id where employee works; foreign key to department_id
column of the departments table';

COMMIT;

REM Script: del_data.sql


REM Purpose: To remove rows, constraints, and code from the hr sample
schema
REM Created: By Nancy Greenberg on 18-MAR-2001
REM for the Introduction to Oracle9i:SQL course
REM This script is invoked by the hr_main script

ALTER TABLE departments


DISABLE CONSTRAINT DEPT_MGR_FK;

ALTER TABLE job_history


DISABLE CONSTRAINT JHIST_EMP_FK;

DROP TRIGGER secure_employees;

DROP TRIGGER update_job_history;

DROP PROCEDURE add_job_history;

DROP PROCEDURE secure_dml;

DELETE FROM employees


WHERE manager_id IN (108, 114, 120, 121, 122, 123, 145, 146, 147, 148);

DELETE FROM employees


WHERE l id IN (114 120 121 122 123 145 146 147 148
https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 62/65
1/9/2018 FULL Script Human Resources for Oracle Database
WHERE employee_id IN (114, 120, 121, 122, 123, 145, 146, 147, 148,
196, 197, 198, 199, 105, 106, 108, 175, 177,
179, 203, 204);

DELETE FROM locations


WHERE location_id NOT IN

(SELECT DISTINCT location_id


FROM departments);

DELETE FROM countries


WHERE country_id NOT IN
(SELECT country_id
FROM locations);

DELETE FROM jobs


WHERE job_id NOT IN
(SELECT job_id

FROM employees);

DELETE FROM departments


WHERE department_id NOT IN
(SELECT DISTINCT department_id
FROM employees
WHERE department_id IS NOT NULL);

UPDATE departments
SET manager_id = 124
WHERE department_id = 50;

UPDATE departments
SET manager_id = 149
WHERE department_id = 80;

DELETE FROM locations


WHERE location_id IN (2700, 2400);

UPDATE locations
SET street_address = '460 Bloor St. W.',
postal_code = 'ON M5S 1X8'
WHERE location_id = 1800;

ALTER TABLE departments


ENABLE CONSTRAINT DEPT_MGR_FK;

CREATE TABLE job_grades


(grade_level VARCHAR2(3),
https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 63/65
1/9/2018 FULL Script Human Resources for Oracle Database
(g _ ( ),
lowest_sal NUMBER,
highest_sal NUMBER);

INSERT INTO job_grades


VALUES ('A', 1000, 2999);

INSERT INTO job_grades


VALUES ('B', 3000, 5999);

INSERT INTO job_grades


VALUES('C', 6000, 9999);

INSERT INTO job_grades


VALUES('D', 10000, 14999);

INSERT INTO job_grades


VALUES('E', 15000, 24999);

INSERT INTO job_grades


VALUES('F', 25000, 40000);

INSERT INTO departments VALUES


( 190
, 'Contracting'
, NULL
, 1700
);

COMMIT;

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 64/65
1/9/2018 FULL Script Human Resources for Oracle Database

https://www.scribd.com/doc/2719944/FULL-Script-Human-Resources-for-Oracle-Database 65/65