0% found this document useful (0 votes)
24 views4 pages

DL

Uploaded by

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

DL

Uploaded by

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

create table EMPLOYEES

(
EMPLOYEE_ID char(20),
FIRST_NAME nvarchar2(100),
LAST_NAME nvarchar2(100),
EMAIL char(100),
PHONE_NUMBER char(20),
HIRE_DATE date,
JOB_ID char(20),
SALARY int,
COMMISSION__PCT nvarchar2(100),
MANAGER_ID char(20),
DEPARTMENT_ID char(20),
primary key(EMPLOYEE_ID)
)

create table JOBS


(
JOB_ID CHAR(20),
JOB_TITLE nvarchar2(100),
MIN_SALARY INT,
MAX_SALARY INT,
primary key(JOB_ID)

)
create table DEPARTMENTS
(
DEPARTMENT_ID char(20),
DEPARTMENT_NAME nvarchar2(100),
MANAGER_ID char(20),
LOCATION_ID CHAR(20),
primary key(DEPARTMENT_ID),
foreign key (LOCATION_ID) references LOCATIONS
)
create table LOCATIONS
(
LOCATION_ID char(20),
STREET_ADDRESS NVARCHAR2(100),
POSTAL_CODE char(20),
CITY NVARCHAR2(100),
STATE_PROVINCE NVARCHAR2(100),
COUNTRY_ID CHAR(20),
primary key(LOCATION_ID),
foreign key(COUNTRY_ID) references COUNTRIES
)

create table COUNTRIES


(
COUNTRY_ID char(20),
COUNTRY_NAME NVARchar2(100),
REGION_ID CHAR(20),
primary key(COUNTRY_ID),
foreign key (REGION_ID) references REGIONS
)

create TABLE REGIONS


(
REGION_ID CHAR(20),
REGION_NAME NVARCHAR2(100),
PRIMARY KEY(REGION_ID)
)

CREATE TABLE JOB_HISTORY


(
EMPLOYEE_ID CHAR(20),
START_DATE DATE,
END_DATE DATE,
JOB_ID CHAR(20),
DEPARTMENT_ID CHAR(20),
PRIMARY KEY(START_DATE, END_DATE),
FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENTS,
FOREIGN KEY (employee_id) REFERENCES employees,
FOREIGN KEY (job_id) REFERENCES jobs
)
drop table job_history

drop table employees


select * from employees
DELETE FROM employees
WHERE employee_id='1811060001'

insert into employees values('1811060001',N'Long',N'Tran Duc


Tien','[email protected]','0123456789','2015/05/15','J001',2000,null,'M001','D001');
insert into employees values('1811060002',N'Hiep',N'Phan Luu
Duc','[email protected]','0934678954','2016/06/16','J001',5500,null,'M001','D001');
insert into employees values('1811060003',N'Tu',N'Nguyen
Anh','[email protected]','09876786543','2017/07/17','J002',6000,null,'M002','D002');
insert into employees values('1811060004',N'Thu',N'Pham Thi
Xuan','[email protected]','0981234567','2018/08/18','J002',6500,null,'M002','D002');
insert into employees values('1811060005',N'Phuong',N'Bui Thi Minh
Phuong','[email protected]','0987123654','2019/09/19','J003',7000,null,'M003','D003');
insert into employees values('1811060006',N'Anh',N'Vu Thi
Phuong','[email protected]','09871256347','2020/02/12','J003',7500,null,'M003','D003')
;
insert into employees values('1811060007',N'Trang',N'Ha Thi
Kieu','[email protected]','0984716497','2009/09/19','J004',8000,null,'M004','D004');
insert into employees values('1811060008',N'Hoang',N'Nguyen
Huy','[email protected]','0873287634','2010/10/10','J004',8500,null,'M004','D004');
insert into employees values('1811060009',N'Huy',N'Tran
Ngoc','[email protected]','0918273645','2008/08/08','J005',9000,null,'M005','D005');
insert into employees values('1811060010',N'Hoc',N'Bui
Duy','[email protected]','0978675645','2007/07/07','J005',13000,null,'M005','D005');

select * from job_history


insert into job_history
values('1811060001','2015/05/16','2016/06/17','J001','D001');
insert into job_history
values('1811060002','2016/06/17','2017/07/18','J001','D001');
insert into job_history
values('1811060003','2017/07/18','2018/08/19','J002','D002');
insert into job_history
values('1811060004','2018/08/19','2019/09/20','J002','D002');
insert into job_history
values('1811060005','2019/09/20','2020/10/21','J003','D003');
insert into job_history
values('1811060006','2020/02/13','2021/03/14','J003','D003');
insert into job_history
values('1811060007','2009/09/20','2012/06/21','J004','D004');
insert into job_history
values('1811060008','2010/10/11','2015/10/20','J004','D004');
insert into job_history
values('1811060009','2008/08/10','2009/06/12','J005','D005');
insert into job_history
values('1811060010','2007/07/09','2021/06/13','J005','D005');

select * from jobs


insert into jobs values('J001',N'Cong Nhan',500,6000);
insert into jobs values('J002',N'Nguoi Quan Ly Du An',2000,7000);
insert into jobs values('J003',N'Nguoi Quan Ly Nhan Su',3000,8000);
insert into jobs values('J004',N'Nguoi quan ly thiet bi may moc',4000,10000);
insert into jobs values('J005',N'Nguoi quan ly phap che',5000,14000);

select * from departments


insert into departments values('D001',N'Phong quan ly cong nhan','M001','L001');
insert into departments values('D002',N'Phong quan ly du an','M002','L002');
insert into departments values('D003',N'Phong quan ly nhan su','M003','L003');
insert into departments values('D004',N'Phong quan ly thiet bi may
moc','M004','L004');
insert into departments values('D005',N'Phong quan ly phap che','M005','L005');

select * from locations


insert into locations values('L001',N'Duong 1, Ngo 1','001',N'TP Ha Noi',N'Ha
Dong','C001');
insert into locations values('L002',N'Duong 2, Ngo 2','002',N'TP Hai Phong',N'Hai
Ba Trung','C002');
insert into locations values('L003',N'Duong 3, Ngo 3','003',N'TP Nam Dinh',N'Ngo
Quyen','C003');
insert into locations values('L004',N'Duong 4, Ngo 4','004',N'TP Bac Ninh',N'Quan A
','C004');
insert into locations values('L005',N'Duong 5, Ngo 5','005',N'TP Viet Tri',N'Quan
B','C005');
insert into locations values('L006',N'Duong 6, Ngo 6','006',N'TP Ha Nam',N'Quan
C','C006');
insert into locations values('L007',N'Duong 7, Ngo 7','007',N'TP Quang Ninh',N'Quan
D','C007');
insert into locations values('L008',N'Duong 8, Ngo 8','008',N'TP Ninh Binh',N'Quan
E','C008');
insert into locations values('L009',N'Duong 9, Ngo 9','009',N'TP DA NANG',N'Quan
F','C009');
insert into locations values('L010',N'Duong 10, Ngo 10','010',N'TP HCM',N'Quan
Nhat','C010');

select * from countries


insert into countries values('C001',N'Ha Noi','R001');
insert into countries values('C002',N'Hai Phong','R002');
insert into countries values('C003',N'Nam Dinh','R003');
insert into countries values('C004',N'Bac Ninh','R004');
insert into countries values('C005',N'Viet Tri','R005');
insert into countries values('C006',N'Ha Nam','R006');
insert into countries values('C007',N'Quang Ninh','R007');
insert into countries values('C008',N'Ninh Binh','R008');
insert into countries values('C009',N'Da Nang','R009');
insert into countries values('C010',N'TP Ho Chi Minh','R010');

select * from regions


insert into regions values('R001',N'Khu Vuc Mot');
insert into regions values('R002',N'Khu Vuc Hai');
insert into regions values('R003',N'Khu Vuc Ba');
insert into regions values('R004',N'Khu Vuc Bon');
insert into regions values'R005',N'Khu Vuc Nam');
insert into regions values('R006',N'Khu Vuc Sau');
insert into regions values('R007',N'Khu Vuc Bay');
insert into regions values('R008',N'Khu Vuc Tam');
insert into regions values('R009',N'Khu Vuc Chin');
insert into regions values('R010',N'Khu Vuc Muoi');

You might also like