Is there a way to add multiple constraints in Oracle at once using the ALTER TABLE command? I know it is possible with SQL server.
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;
Error message:
Error report -
ORA-01735: invalid ALTER TABLE option
01735. 00000 - "invalid ALTER TABLE option"
*Cause:
*Action:
Place the constraints in parentheses:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With