Created
August 10, 2020 00:51
-
-
Save legarnica/8d1c6051071dfef689b699bc961237ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DROP TABLE "JOB_HISTORY"; | |
-- DROP TABLE "EMPLOYEES"; | |
-- DROP TABLE "DEPARTMENTS"; | |
-- DROP TABLE "JOBS"; | |
-- DROP TABLE "LOCATIONS"; | |
-- DROP TABLE "COUNTRIES"; | |
-- DROP TABLE "REGIONS"; | |
CREATE TABLE "REGIONS" | |
( "REGION_ID" NUMBER CONSTRAINT "REGION_ID_NN" NOT NULL ENABLE, | |
"REGION_NAME" VARCHAR2(25), | |
CONSTRAINT "REG_ID_PK" PRIMARY KEY ("REGION_ID") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE | |
) SEGMENT CREATION IMMEDIATE | |
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ; | |
CREATE TABLE "COUNTRIES" | |
( "COUNTRY_ID" CHAR(2) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE, | |
"COUNTRY_NAME" VARCHAR2(40), | |
"REGION_ID" NUMBER, | |
CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE, | |
CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") | |
REFERENCES "REGIONS" ("REGION_ID") ENABLE | |
) ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" | |
PCTTHRESHOLD 50; | |
CREATE TABLE "LOCATIONS" | |
( "LOCATION_ID" NUMBER(4,0), | |
"STREET_ADDRESS" VARCHAR2(40), | |
"POSTAL_CODE" VARCHAR2(12), | |
"CITY" VARCHAR2(30) CONSTRAINT "LOC_CITY_NN" NOT NULL ENABLE, | |
"STATE_PROVINCE" VARCHAR2(25), | |
"COUNTRY_ID" CHAR(2), | |
CONSTRAINT "LOC_ID_PK" PRIMARY KEY ("LOCATION_ID") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE, | |
CONSTRAINT "LOC_C_ID_FK" FOREIGN KEY ("COUNTRY_ID") | |
REFERENCES "COUNTRIES" ("COUNTRY_ID") ENABLE | |
) SEGMENT CREATION IMMEDIATE | |
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ; | |
CREATE TABLE "JOBS" | |
( "JOB_ID" VARCHAR2(10), | |
"JOB_TITLE" VARCHAR2(35) CONSTRAINT "JOB_TITLE_NN" NOT NULL ENABLE, | |
"MIN_SALARY" NUMBER(6,0), | |
"MAX_SALARY" NUMBER(6,0), | |
CONSTRAINT "JOB_ID_PK" PRIMARY KEY ("JOB_ID") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE | |
) SEGMENT CREATION IMMEDIATE | |
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ; | |
CREATE TABLE "DEPARTMENTS" | |
( "DEPARTMENT_ID" NUMBER(4,0), | |
"DEPARTMENT_NAME" VARCHAR2(30) CONSTRAINT "DEPT_NAME_NN" NOT NULL ENABLE, | |
"MANAGER_ID" NUMBER(6,0), | |
"LOCATION_ID" NUMBER(4,0), | |
CONSTRAINT "DEPT_ID_PK" PRIMARY KEY ("DEPARTMENT_ID") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE, | |
CONSTRAINT "DEPT_LOC_FK" FOREIGN KEY ("LOCATION_ID") | |
REFERENCES "LOCATIONS" ("LOCATION_ID") ENABLE) | |
TABLESPACE "USERS" ; | |
CREATE TABLE "EMPLOYEES" | |
( "EMPLOYEE_ID" NUMBER(6,0), | |
"FIRST_NAME" VARCHAR2(20), | |
"LAST_NAME" VARCHAR2(25) CONSTRAINT "EMP_LAST_NAME_NN" NOT NULL ENABLE, | |
"EMAIL" VARCHAR2(25) CONSTRAINT "EMP_EMAIL_NN" NOT NULL ENABLE, | |
"PHONE_NUMBER" VARCHAR2(20), | |
"HIRE_DATE" DATE CONSTRAINT "EMP_HIRE_DATE_NN" NOT NULL ENABLE, | |
"JOB_ID" VARCHAR2(10) CONSTRAINT "EMP_JOB_NN" NOT NULL ENABLE, | |
"SALARY" NUMBER(8,2), | |
"COMMISSION_PCT" NUMBER(2,2), | |
"MANAGER_ID" NUMBER(6,0), | |
"DEPARTMENT_ID" NUMBER(4,0), | |
CONSTRAINT "EMP_SALARY_MIN" CHECK (salary > 0) ENABLE, | |
CONSTRAINT "EMP_EMAIL_UK" UNIQUE ("EMAIL") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE, | |
CONSTRAINT "EMP_EMP_ID_PK" PRIMARY KEY ("EMPLOYEE_ID") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE, | |
CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") | |
REFERENCES "DEPARTMENTS" ("DEPARTMENT_ID") ENABLE, | |
CONSTRAINT "EMP_JOB_FK" FOREIGN KEY ("JOB_ID") | |
REFERENCES "JOBS" ("JOB_ID") ENABLE, | |
CONSTRAINT "EMP_MANAGER_FK" FOREIGN KEY ("MANAGER_ID") | |
REFERENCES "EMPLOYEES" ("EMPLOYEE_ID") ENABLE | |
) SEGMENT CREATION IMMEDIATE | |
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ; | |
CREATE TABLE "JOB_HISTORY" | |
( "EMPLOYEE_ID" NUMBER(6,0) CONSTRAINT "JHIST_EMPLOYEE_NN" NOT NULL ENABLE, | |
"START_DATE" DATE CONSTRAINT "JHIST_START_DATE_NN" NOT NULL ENABLE, | |
"END_DATE" DATE CONSTRAINT "JHIST_END_DATE_NN" NOT NULL ENABLE, | |
"JOB_ID" VARCHAR2(10) CONSTRAINT "JHIST_JOB_NN" NOT NULL ENABLE, | |
"DEPARTMENT_ID" NUMBER(4,0), | |
CONSTRAINT "JHIST_DATE_INTERVAL" CHECK (end_date > start_date) ENABLE, | |
CONSTRAINT "JHIST_EMP_ID_ST_DATE_PK" PRIMARY KEY ("EMPLOYEE_ID", "START_DATE") | |
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ENABLE, | |
CONSTRAINT "JHIST_JOB_FK" FOREIGN KEY ("JOB_ID") | |
REFERENCES "JOBS" ("JOB_ID") ENABLE, | |
CONSTRAINT "JHIST_EMP_FK" FOREIGN KEY ("EMPLOYEE_ID") | |
REFERENCES "EMPLOYEES" ("EMPLOYEE_ID") ENABLE, | |
CONSTRAINT "JHIST_DEPT_FK" FOREIGN KEY ("DEPARTMENT_ID") | |
REFERENCES "DEPARTMENTS" ("DEPARTMENT_ID") ENABLE | |
) SEGMENT CREATION IMMEDIATE | |
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING | |
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 | |
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) | |
TABLESPACE "USERS" ; | |
ALTER TABLE "DEPARTMENTS" ADD CONSTRAINT "DEPT_MGR_FK" FOREIGN KEY ("MANAGER_ID") | |
REFERENCES "EMPLOYEES" ("EMPLOYEE_ID") ENABLE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment