Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Oracle think I'm missing a right parenthesis?

In Oracle 10i, I'm running the following command:

ALTER TABLE jnrvwchnglst ADD
     ( jnrvwchnglst_userid NUMBER(10) NOT NULL DEFAULT 1 )

Yes jnrvwchnglst is an existing table and no jnrvwchnglst_userid is not an existing column.

The Oracle error message is:

ORA-00907: missing right parenthesis

What's wrong with this query and why does Oracle think I'm missing a parenthesis?

like image 749
Jason Cohen Avatar asked Apr 01 '09 17:04

Jason Cohen


People also ask

How do you fix missing parentheses in Oracle?

To correct this error, you must find the part of code that contains the missing right parenthesis, insert the missing symbol in the correct spot, and run the statement again.

Why is SQL showing missing right parenthesis?

ORA-00907: missing right parenthesis error occurs when a left parenthesis is used without a right parenthesis to close it in SQL statements such as create table, insert, select, subquery, and IN clause. The right parenthesis is missing. All parentheses must be used in pairs.

What is meant by right parenthesis?

The right parenthesis symbol is used in combination with the left parenthesis symbol to group one or more expressions together. Specifically, the right parenthesis symbol marks the end of a group. Parentheses are also used to represent multiplciation and within the notation of a function.

How do I find missing parentheses in SQL?

Solution 1 – Check Your Pairs of Parentheses If you're using an IDE such as SQL Developer, you can put your cursor next to each parenthesis to see where the matching parenthesis is. If it's in the right spot, great. If the match is showing up somewhere unexpected, then you're missing a parenthesis.


2 Answers

ALTER TABLE jnrvwchnglst ADD
     ( jnrvwchnglst_userid NUMBER(10) DEFAULT 1  NOT NULL )
like image 106
Quassnoi Avatar answered Oct 05 '22 04:10

Quassnoi


"(NOT) NULL" must be the last statement in the "ALTER" syntactically when present, so when Oracle saw that - and that the next char (your "DEFAULT" stmt) wasn't the expected terminating right ")", threw the error.

like image 39
galaxis Avatar answered Oct 05 '22 06:10

galaxis