Let object id within second table be unique
-
14-07-2021 - |
Question
I got the following sql:
create or replace type MEDIUM_TYPE AS OBJECT
(
me_movie REF MOVIE_TYPE,
me_rating varchar2(2),
me_runtime number(3,0),
me_release_year number(4,0),
me_list_price number(3,2),
me_our_price number(3,2),
me_availability varchar2(128),
me_aspect_ratio varchar2(8),
me_encoding number (1,0),
me_subtitle_language SUBTITLE_LANGUAGE_TYPE,
me_number_of_discs number (1,0)
)not final
/
create table DVD of MEDIUM_TYPE
object id system generated
/
How can i make sure that me_movie in the dvd table is unique?
And also, how can i do something like this?
mo_release_year number(4,0) BETWEEN 1900 AND 2100,
Solution
It's pretty much the same syntax as for relational tables:
create table DVD of MEDIUM_TYPE
( me_movie primary key )
object id system generated
/
The one problem you have is that you will run into this error:
ORA-02329: column of datatype REF cannot be unique or a primary key
Which admittedly is a bit of a showstopper. You will need to re-think your whole model. Sorry about that.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow