Algo
Algo

Reputation: 91

unable to run sql file in ubuntu command line

I have typed the following query in command line and it worked but when I try to run it through the command @..../filename.sql the first query works but the second doesn't...I can't figure out why. need help. Also the Error message I am getting reads SP2-0042 Unknown command ")" - rest of line ignored

here is the query

/** Query 1: works through terminal and by calling @.../filename.sql**/

CREATE TABLE CUSTOMER
( cID   NUMBER NOT NULL,
  firstName     VARCHAR2(50) NOT NULL,
  lastName  VARCHAR2(50) NOT NULL,
  streetAddress VARCHAR2(50),
    CONSTRAINT CUSTOMER_PK PRIMARY KEY (customerID) 
);

/**Query2: only works through terminal**/

CREATE TABLE ADDRESS
( 
  cID   NUMBER NOT NULL,
  city          VARCHAR2(50) NOT NULL,
  zipCode       VARCHAR2(50) NOT NULL,
    CONSTRAINT FK_CUSTOMER_ADDRESS FOREIGN KEY (cID) REFERENCES CUSTOMER(cID) ON UPDATE CASCADE

);

Upvotes: 0

Views: 205

Answers (2)

user330315
user330315

Reputation:

Oracle does not support ON UPDATE CASCADE, it only supports ON DELETE CASCADE.

https://docs.oracle.com/cd/E11882_01/server.112/e41084/clauses002.htm#CJAIHHGC

So apart from the empty line (that Allan already pointed out), you need to remove the ON UPDATE CASCADE for the foreign key.

Upvotes: 1

Allan
Allan

Reputation: 17429

SQL Plus doesn't like empty lines in the middle of DDL (for non-procedural objects). Remove the empty line before the closing parenthesis or run set sqlblanklines on before running that DDL.

Upvotes: 1

Related Questions