-
Notifications
You must be signed in to change notification settings - Fork 0
/
HW4.ddl2
80 lines (72 loc) · 1.91 KB
/
HW4.ddl2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
DROP SEQUENCE SIM_Person_seq ;
create sequence SIM_Person_seq
start with 100
increment by 1
nomaxvalue
;
DROP TRIGGER SIM_Person_PK_trig
;
create or replace trigger SIM_Person_PK_trig
before insert on SIM_Person
for each row
begin
select SIM_Person_seq.nextval into :new.person_id from dual;
end;
/
DROP SEQUENCE SIM_dept_seq ;
create sequence SIM_dept_seq
start with 100
increment by 1
nomaxvalue
;
DROP TRIGGER SIM_dept_PK_trig
;
create or replace trigger SIM_dept_PK_trig
before insert on SIM_dept
for each row
begin
select SIM_dept_seq.nextval into :new.dept_id from dual;
end;
/
DROP SEQUENCE SIM_project_seq ;
create sequence SIM_project_seq
start with 100
increment by 1
nomaxvalue
;
DROP TRIGGER SIM_project_PK_trig
;
create or replace trigger SIM_project_PK_trig
before insert on SIM_project
for each row
begin
select SIM_project_seq.nextval into :new.project_id from dual;
end;
/
DROP SEQUENCE SIM_project_rel_seq ;
create sequence SIM_project_rel_seq
start with 100
increment by 1
nomaxvalue
;
DROP TRIGGER SIM_project_rel_PK_trig
;
create or replace trigger SIM_project_rel_PK_trig
before insert on SIM_project_rel
for each row
begin
select SIM_project_rel_seq.nextval into :new.dept_id from dual;
end;
/
DROP INDEX SIM_dept_dept_id_FK_0 ;
CREATE INDEX SIM_dept_dept_id_FK_0 ON SIM_Person(SIM_dept_dept_id) ;
DROP INDEX SIM_dept_dept_id1_FK_1 ;
CREATE INDEX SIM_dept_dept_id1_FK_1 ON SIM_Person(SIM_dept_dept_id1) ;
DROP INDEX SIM_Person_person_id_FK_2 ;
CREATE INDEX SIM_Person_person_id_FK_2 ON SIM_dept(SIM_Person_person_id) ;
DROP INDEX SIM_dept_dept_id_FK_3 ;
CREATE INDEX SIM_dept_dept_id_FK_3 ON SIM_project(SIM_dept_dept_id) ;
DROP INDEX SIM_Person_person_id_FK_4 ;
CREATE INDEX SIM_Person_person_id_FK_4 ON SIM_project_rel(SIM_Person_person_id) ;
DROP INDEX SIM_project_project_id_FK_5 ;
CREATE INDEX SIM_project_project_id_FK_5 ON SIM_project_rel(SIM_project_project_id) ;