Skip to content

Commit 786cc0b

Browse files
authored
Create 6-using-builtin-domains.sql
1 parent 49528e8 commit 786cc0b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
REM script for 23c: 6-using-builtin-domains.sql
2+
REM Oracle provides built-in domains you can use directly on table columns.
3+
4+
-- query ALL_DOMAINS and filter on SYS
5+
select name from all_domains where owner='SYS';
6+
7+
-- Let's investigate the domain EMAIL_D
8+
9+
set long 1000
10+
set longc 1000
11+
select dbms_metadata.get_ddl('SQL_DOMAIN', 'EMAIL_D','SYS') domain_ddl from dual;
12+
13+
-- Now let's re-create the table PERSON.
14+
-- Please keep in mind that we need to adjust the length of the column P_EMAIL to 4000 - otherwise you will receive the following error:ORA-11517: the column data type does not match the domain column
15+
16+
drop table person;
17+
18+
create table person
19+
( p_id number(5),
20+
p_name varchar2(50),
21+
p_sal number,
22+
p_email varchar2(4000) domain EMAIL_D
23+
)
24+
annotations (display 'person_table');
25+
26+
--let's insert valid and invalid data
27+
28+
insert into person values (1,'Bold',3000,null);
29+
30+
insert into person values (1,'Schulte',1000, '[email protected]');
31+
32+
insert into person values (1,'Walter',1000,'twalter@t_online.de');

0 commit comments

Comments
 (0)