I have to create a table and add the below constraints to CREATE TABLE statement
ID: 3625885 • Letter: I
Question
I have to create a table and add the below constraints to CREATE TABLE statements When I input this code into my Linux SSH Secure Shell I then get the following error:"ERROR at line 8:
ORA-02253: constraint specification not allowed here"
Everything is spelled correctly, so I'm not sure sure what is wrong anddd I have to make 9 more of these tables (also with constraints). Please help :)
create table ITEMS (
ORDER_ID NUMBER(4) NOT NULL,
ITEM_ID NUMBER(4) NOT NULL,
PRODUCT_ID NUMBER(6),
ACTUAL_PRICE NUMBER(8,2),
QUANTITY NUMBER(8),
TOTAL NUMBER(8,2)
CONSTRAINT fk_products
FOREIGN KEY (product_id)
REFERENCES products (product_id),
CONSTRAINT fk_sales_orders
FOREIGN KEY (order_id)
REFERENCES sales_orders (order_id));
Explanation / Answer
In the case of inline constraints, the keyword foreign key is not needed.
It can be simply written as
CONSTRAINT fk_products
REFERENCES products (product_id),