Search code examples
sqloracle-databaseora-00907

Hi, I am truing create SQl table and I am keeping getting this error ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis"


Error starting at line : 1 in command -
CREATE TABLE DEAD( 
DEATH_ID INTEGER(10) NOT NULL,
DEATHYEAR INTEGER NOT NULL,
PRIMARY KRY(DEATH_ID)
)
Error report -
ORA-00907: missing right parenthesis
00907. 00000 -  "missing right parenthesis"
*Cause:    
*Action:

Solution

  • In Oracle, integer does not take a length. number does, so:

    CREATE TABLE DEAD ( 
        DEATH_ID NUMBER(10) PRIMARY KEY,
        DEATHYEAR INTEGER NOT NULL
    )
    

    Here is a db<>fiddle.

    Note that I replaced the separate primary key constraint with an in-line constraint. NOT NULL is redundant on a `PRIMARY KEY.