Skip to content

Commit eb818f1

Browse files
authored
Create domain.sql
1 parent 581c6e1 commit eb818f1

File tree

1 file changed

+41
-0
lines changed
  • data-platform/core-converged-db/database-23c/23c-basic-examples

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
REM Script in 23c: domain.sql
2+
3+
drop domain yearbirth;
4+
5+
create domain yearbirth as number(4)
6+
constraint check ((trunc(yearbirth) = yearbirth) and (yearbirth >= 1900))
7+
display (case when yearbirth < 2000 then '19-' ELSE '20-' end)||mod(yearbirth, 100)
8+
order (yearbirth -1900)
9+
annotations (title 'yearformat');
10+
11+
drop table person;
12+
create table person
13+
( id number(5),
14+
name varchar2(50),
15+
salary number,
16+
person_birth number(4) DOMAIN yearbirth
17+
)
18+
annotations (display 'person_table');
19+
20+
desc person
21+
22+
insert into person values (1,'MARTIN',3000, 1988);
23+
24+
select DOMAIN_DISPLAY(person_birth) from person;
25+
26+
-- monitor domains
27+
set linesize window
28+
col object_name format a20
29+
col object_type format a15
30+
col column_name format a15
31+
col annotation_value format a25
32+
col annotation_name format a20
33+
col domain_owner format a10
34+
col domain_name format a15
35+
36+
select * from user_annotations_usage;
37+
38+
col owner format a10
39+
col name format a15
40+
41+
select * from user_domains;

0 commit comments

Comments
 (0)