繁体   English   中英

对子类型属性的约束(Oracle)

[英]Constraint on subtype attribute (Oracle)

如果我有一个类型x_typ和子类型y_typ,是否可以创建一个x_typ的对象表,但是对其中一个y_typ属性设置了约束,即

create table x_table of x_typ (
   constraint constr_y check (y_typ.attribute1 < 5);
);

谢谢

我能来的最近的是......

CREATE OR REPLACE TYPE x_typ AS OBJECT (record_type varchar2(1)) NOT FINAL;
/

CREATE OR REPLACE TYPE y_typ UNDER x_typ (attribute1 number) ;
/

create table x_table (x_col x_typ);


alter table x_table add constraint x_cons 
  check ( 1 = case when x_col is of (y_typ) then 
      treat (x_col as y_typ).attribute1 else 1 end);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM