aboutsummaryrefslogtreecommitdiff
path: root/res/sql/tables/orcl_add_constraints_defaults.sql
blob: 4fd386c4aff1ad318d914a443bf878b79a03ce42 (plain)
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
-- constraints

ALTER TABLE USERS
ADD CONSTRAINT username_unique UNIQUE (USERNAME);


-- defaults

-- oracle can not use user defined functions (gen_uuid()) as default values :c

ALTER TABLE USERS
MODIFY UUID DEFAULT regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5');

ALTER TABLE BIDS
MODIFY UUID DEFAULT regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5');

ALTER TABLE CHARGES
MODIFY UUID DEFAULT regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5');

ALTER TABLE ITEMS
MODIFY UUID DEFAULT regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5');

ALTER TABLE TRANSACTIONS
MODIFY UUID DEFAULT regexp_replace(rawtohex(sys_guid())
, '([A-F0-9]{8})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{4})([A-F0-9]{12})'
, '\1-\2-\3-\4-\5');

COMMIT;