-
Notifications
You must be signed in to change notification settings - Fork 24
/
create_schema.sql
52 lines (39 loc) · 897 Bytes
/
create_schema.sql
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
@drop_schema
create user just_a_schema
identified by x
quota unlimited on users;
grant
create session,
create table,
create sequence,
create trigger
to
just_a_schema;
connect just_a_schema/x
create table a_tbl (
id number primary key,
txt varchar2(20)
);
create sequence a_seq;
create trigger a_trg
before insert or update on a_tbl
for each row
begin
:new.id := a_seq.nextval;
end a_trg;
/
insert into a_tbl(txt) values ('record #1');
insert into a_tbl(txt) values ('record #2');
insert into a_tbl(txt) values ('record #3');
-- select * from a_tbl;
create table b_tbl (
id_a number not null references a_tbl,
txt varchar2(20)
);
insert into b_tbl values (1, 'foo');
insert into b_tbl values (1, 'bar');
insert into b_tbl values (1, 'baz');
insert into b_tbl values (2, 'hello');
insert into b_tbl values (2, 'world');
-- select * from b_tbl;
commit;