[RESOLVED] Oracle SQL Developer Composite Key
This is my first time using Oracle SQL Developer and the statements I'm used to using in MS SQL Server seems to not work on this environment say for example with the use of the following Query:
Code:
/* Code by K0502201*/
CREATE TABLE tblPrice
(
StoreID SMALLINT REFERENCES tblStore(StoreID),
ProdCode CHAR(8) REFERENCES tblProduct(ProdCode),
PricePU NUMERIC(4,2)
CONSTRAINT PriceCK PRIMARY KEY
(StoreID, ProdCode)
);
It gave me the following error:
Code:
Error at Command Line:8 Column:2
Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Which doesn't make sense at all to me. Both tblStore and tblProduct has already been created :(
Any help is greatly appreciated.
Re: Oracle SQL Developer Composite Key
Oracle does not work like SQL Server.
sql Code:
Create Table tblPrice (
StoreID Number NOT NULL,
ProdCode varchar2(8) NOT NULL,
PricePU Number(4,2)
);
Alter Table tblPrice
Add Constraint tblPrice$PK Primary Key
(StoreID,ProdCode);
Alter Table tblPrice
Add Constraint tblPrice#FK1 Foreign Key
(StoreID)
References tblStore;
Alter Table tblPrice
Add Constraint tblPrice#FK2 Foreign Key
(ProdCode)
References tblProdCode;
Re: [RESOLVED] Oracle SQL Developer Composite Key
Thanks,
I never knew that it will take that much code to put it onto Oracle :D
Thanks again,