Results 1 to 3 of 3

Thread: [RESOLVED] Oracle SQL Developer Composite Key

  1. #1

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Resolved [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.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Oracle SQL Developer Composite Key

    Oracle does not work like SQL Server.

    sql Code:
    1. Create Table tblPrice (
    2.    StoreID    Number NOT NULL,
    3.    ProdCode  varchar2(8) NOT NULL,
    4.    PricePU    Number(4,2)
    5. );
    6. Alter Table tblPrice
    7.   Add Constraint tblPrice$PK Primary Key
    8.      (StoreID,ProdCode);
    9.  
    10. Alter Table tblPrice
    11.      Add Constraint tblPrice#FK1 Foreign Key
    12.              (StoreID)
    13.        References tblStore;
    14. Alter Table tblPrice
    15.      Add Constraint tblPrice#FK2 Foreign Key
    16.              (ProdCode)
    17.        References tblProdCode;
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Hyperactive Member Greyskull's Avatar
    Join Date
    Dec 2003
    Location
    somewhere in England
    Posts
    382

    Re: [RESOLVED] Oracle SQL Developer Composite Key

    Thanks,

    I never knew that it will take that much code to put it onto Oracle

    Thanks again,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width