0% found this document useful (0 votes)
20 views2 pages

Test

This document contains SQL commands to create three database tables: COUNTRIES, DEPARTMENTS, and EMPLOYEES. The COUNTRIES table has fields for country ID, name, and region ID. The DEPARTMENTS table stores department ID, name, manager ID, and location ID. The EMPLOYEES table begins to define fields for employee ID, first name, and last name. Comments are added to describe the purpose of each column. Indexes are created on the primary key fields of each table.

Uploaded by

Jack Sparow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Test

This document contains SQL commands to create three database tables: COUNTRIES, DEPARTMENTS, and EMPLOYEES. The COUNTRIES table has fields for country ID, name, and region ID. The DEPARTMENTS table stores department ID, name, manager ID, and location ID. The EMPLOYEES table begins to define fields for employee ID, first name, and last name. Comments are added to describe the purpose of each column. Indexes are created on the primary key fields of each table.

Uploaded by

Jack Sparow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

This is a Test.

CREATE TABLE COUNTRIES


(
COUNTRY_ID CHAR (2 BYTE) NOT NULL ,
COUNTRY_NAME VARCHAR2 (40 BYTE) ,
REGION_ID NUMBER
) LOGGING
;

COMMENT ON COLUMN COUNTRIES.COUNTRY_ID IS 'Primary key of countries table.'


;

COMMENT ON COLUMN COUNTRIES.COUNTRY_NAME IS 'Country name'


;

COMMENT ON COLUMN COUNTRIES.REGION_ID IS 'Region ID for the country.


Foreign key to region_id column in the departments table.'
;

CREATE UNIQUE INDEX COUNTRY_C_ID_PKX ON COUNTRIES


(
COUNTRY_ID ASC
)
;

ALTER TABLE COUNTRIES


ADD CONSTRAINT COUNTRY_C_ID_PK PRIMARY KEY ( COUNTRY_ID ) ;

CREATE TABLE DEPARTMENTS


(
DEPARTMENT_ID NUMBER (4) NOT NULL ,
DEPARTMENT_NAME VARCHAR2 (30 BYTE) NOT NULL ,
MANAGER_ID NUMBER (6) ,
LOCATION_ID NUMBER (4)
) LOGGING
;

COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of


departments table.'
;

COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that


shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. '
;

COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department.


Foreign key to employee_id column of employees table. The manager_id column
of the employee table references this column.'
;
COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a
department is located. Foreign key to location_id column of locations
table.'
;

CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS


(
LOCATION_ID ASC
)
LOGGING
NOCOMPRESS
NOPARALLEL
;

CREATE UNIQUE INDEX DEPT_ID_PKX ON DEPARTMENTS


(
DEPARTMENT_ID ASC
)
;

ALTER TABLE DEPARTMENTS


ADD CONSTRAINT DEPT_ID_PK PRIMARY KEY ( DEPARTMENT_ID ) ;

CREATE TABLE EMPLOYEES


(
EMPLOYEE_ID NUMBER (6) NOT NULL ,
FIRST_NAME VARCHAR2 (20 BYTE) ,
LAST

You might also like