Mae*_*ex1 2 oracle constraints
有没有办法使用ALTER TABLE命令一次在 Oracle 中添加多个约束?我知道使用 SQL 服务器是可能的。
ALTER TABLE l_customer_order
ADD CONSTRAINT pk_l_customer_order
PRIMARY KEY (customer_order_id_hk),
CONSTRAINT fk_customer_id_hk
FOREIGN KEY (customer_id_hk)
REFERENCES h_customers(customer_id_hk)
ON DELETE CASCADE,
CONSTRAINT fk_order_id_hk
FOREIGN KEY (order_id_hk)
REFERENCES h_orders(order_id_hk)
ON DELETE CASCADE;
Run Code Online (Sandbox Code Playgroud)
错误信息:
Error report -
ORA-01735: invalid ALTER TABLE option
01735. 00000 - "invalid ALTER TABLE option"
*Cause:
*Action:
Run Code Online (Sandbox Code Playgroud)
将约束放在括号中:
create table t (
c1 int, c2 int, c3 int
);
alter table t
add (
constraint pk
primary key ( c1 ),
constraint ck
check ( c2 > 0 )
);
select constraint_name
from user_constraints
where table_name = 'T';
CONSTRAINT_NAME
CK
PK
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1203 次 |
| 最近记录: |