Hi
Please why I got this error(SQL Error: ORA-00907: missing right parenthesis) whats wrong in my code?

CREATE TABLE artphoto(
        photonr NUMBER(10),
        artnr   NUMBER(10) NOT NULL,
        filtyp  VARCHAR2(5) NOT NULL,
        path    VARCHAR2(100) NOT NULL,

        CONSTRAINT artphoto_photonr_pk PRIMARY KEY(photonr),
        CONSTRAINT artphoto_artnr_fk FOREIGEN KEY(artnr),
            REFERENCES art(artnr),
        CONSTRAINT artphoto_filtyp_ck CHECK(filtyp in ('gif','jpg'))
);

Error starting at line 1 in command:

CREATE TABLE artphoto(
        photonr NUMBER(10),
        artnr   NUMBER(10) NOT NULL,
        filtyp  VARCHAR2(3) NOT NULL,
        path    VARCHAR2(200) NOT NULL,

        CONSTRAINT artphoto_photonr_pk PRIMARY KEY(photonr),
        CONSTRAINT artphoto_artnr_fk FOREIGEN KEY(artnr),
            REFERENCES art(artnr),
        CONSTRAINT artphoto_filtyp_ck CHECK(filtyp in ('gif','jpg'))

)
Error at Command Line:8 Column:44
Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"

try removing the comma after the last column and put your right paren there. you need to actually create the table before you can add any constraints.

Thanks Sir
You mean like this?

CONSTRAINT artphoto_artnr_fk FOREIGEN KEY(artnr),
REFERENCES art(artnr))

there are two erros in this:-

  • spelling of FOREIGEN KEY.Change it to "FOREIGN KEY"

  • remove comma before REFERENCES.

So the final query must be like this

CREATE TABLE artphoto(
        photonr NUMBER(10),
        artnr   NUMBER(10) NOT NULL,
        filtyp  VARCHAR2(3) NOT NULL,
        path    VARCHAR2(200) NOT NULL,

        CONSTRAINT artphoto_photonr_pk PRIMARY KEY(photonr),
        CONSTRAINT artphoto_artnr_fk FOREIGN KEY(artnr)  REFERENCES art(artnr),
        CONSTRAINT artphoto_filtyp_ck CHECK(filtyp in ('gif','jpg'))
        );

Hope it solves your problem.

Thank you very much:)

SQL> CREATE TABLE client_master(client_name varchar(8) PRIMARY KEY,name VARCHAR(30) NOT NULL,address VARCHAR(25) NOT NULL,city VARCHAR(10) NOT NULL,pin_code NUMBER(08) NOT NULL,state VARCHAR(15) NOT NULL,Balance_Due VARCHAR(10,2) NOT NULL);

ERROR at line 1:
ORA-00907: missing right parenthesis

showing this.... what should i do????

CREATE TABLE client_master(client_name varchar(8) PRIMARY KEY,name VARCHAR(30) NOT NULL,address VARCHAR(25) NOT NULL,city VARCHAR(10) NOT NULL,pin_code NUMBER(08) NOT NULL,state VARCHAR(15) NOT NULL,Balance_Due VARCHAR(10) NOT NULL);

CREATE TABLE SALESORDER(
ORDERNO VARCHAR(6) PRIMARY KEY CHECK(ORDERNO LIKE 'O%'),
CLIENT_NO VARCHAR(6) FOREIGN KEY REFERENCES CLIENT_MAST(CLIENTNO),
ORDERDATE DATE NOT NULL,
DELYADDR VARCHAR(25),
SALESMANNO VARCHAR(6) FOREIGN KEY REFERENCES SALESMAN_MAST(SALESMANNO),
DELYTYPE CHAR(1),
BILLYN CHAR(1),
DELYDATE DATE CHECK(BELYDATE > ORDERDATE),
ORDERSTATUS VARCHAR(10) CHECK(ORDERSTATUS IN('PROCESS','FULFILLED,'BACKORDER,'CANCELLED'))
);

IT GENRATE BELOW ERROR HOW TO SOLVE IT:

ORA-00907: missing right parenthesis

Just go through the code and check each pair of open/close parenthese. Either you are missing , or you have an extra, unmatched one. If that's OK then you are missing a whole block of syntax.

But next time DO NOT hijack an old topic - start you own new topic.

IN('PROCESS','FULFILLED,'BACKORDER,'CANCELLED'))
can you spot the error? Look at the ' and the ,

commented: Well spotted! +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.