Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: create own datatypes
Hi
Try this
Oracle 8..x Enterprise Edition with the Objects option installed.
Create an abstract datatype as:
create type DT_ADDRESS as object (
street varchar2(20),
town varchar2(20),
city varchar2(20),
postcode varchar2(10));
Create a table using the abstract datatype as:
create table CUSTOMER (
id varchar2(6),
customer_name varchar2(20),
address dt_address);
Insert data into the customer table :
insert into CUSTOMER values
(1234,'ACME','DT_ADDRESS('5 mystreet','mytown','mycity','mypostcvode');
Select data from CUSTOMER this works
select * from CUSTOMER;
select address.* from customer;
To select an individual column from the abstract datatype use
Sql> select C.address.city from customer c;
Alias customer with C, use c.address.<attribute>
Hope it helps
Alistair
Markus Kehrls <Markus.Kehrls_at_Synnotech.de> wrote in message
news:9n7vr2$60tj8$1_at_ID-5151.news.dfncis.de...
> Hello to all!
>
> Is there the possibility in oracle to create my own datatype (no objects
or
> records)?
> I want to do the following:
>
> create DTusername = varchar(30) file://my own datatype
>
> Then i want to use DTusername for example in one table:
>
> create table test_table ( username DTusername );
>
> The advantage of this method is that everybody who create his table is
> using for username automatically varchar(30), and every table has the same
> type.
> In Sybase there is i think the possibility. in borlands interbase it works
> with create domain.
> I asked specialists, but nobody knows or they say it doesn't work.
>
> Thank you for answering,
> Markus
>
>
>
>
Received on Thu Sep 06 2001 - 09:57:20 CDT
![]() |
![]() |