Skip to content
Oracle Database

Oracle Error ORA-00907

missing right parenthesis

Applies to: Oracle Database 19c, 21c, 23ai and 26ai (same wording)
Last technically reviewed 24 October 2026 on Oracle Database Error Messages reference (26ai, 21c and 19c); not run locally
The full message
ORA-00907: missing right parenthesis
Other forms of this message
SQL*Plus and SQLcl mark where parsing stopped
    id NUMBER PRIMARY KEY AUTO_INCREMENT,
                          *
ERROR at line 2:
ORA-00907: missing right parenthesis
Error code
ORA-00907
Product
Oracle Database
Versions
Oracle Database 19c, 21c, 23ai and 26ai (same wording)
Last reviewed
24 October 2026

What it means

ORA-00907 means Oracle reached a point inside parentheses where it expected the closing ")" and found something else: either a parenthesis really is missing, or the parentheses contain a word or clause Oracle does not accept there.

Oracle's reference gives two causes: a left parenthesis entered without a closing right parenthesis, or unrecognised information inside the parentheses. The second is the one that confuses people. When the parser meets a keyword it does not expect in a column list, a function call or a subquery, it assumes the parenthesised part should have ended there and reports a missing right parenthesis, even if every bracket is balanced.

So read the error as "something is wrong at or just before this position inside the brackets". Typical culprits are syntax from other databases in CREATE TABLE (AUTO_INCREMENT, a size on a type that takes none, a misplaced constraint clause), an ORDER BY inside an IN subquery, and a missing comma between two column definitions. SQL*Plus and SQLcl print an asterisk under the token where parsing stopped, which is usually the word to look at.

Common causes

  • A closing parenthesis really is missing, often in nested function calls or a long IN list.
  • CREATE TABLE uses syntax from another database, such as AUTO_INCREMENT, IDENTITY(1,1) or UNSIGNED, inside the column list.
  • A subquery used with IN, EXISTS or a comparison contains an ORDER BY clause.
  • A comma is missing between two column or constraint definitions, so the next definition is read as part of the previous one.
  • A constraint clause is written in the wrong place or form, for example an inline constraint with a column list.

Diagnose it

Read-only These queries only read the data dictionary (USER_, ALL_ and DBA_ views) and dynamic performance views (V$). They do not change data, privileges or settings, so they are safe to run first. DBA_ and V$ views need the matching privileges.

Look at the token Oracle marks

In SQL*Plus or SQLcl the asterisk under the statement and "ERROR at line N" show where parsing stopped. In SQL Developer and most drivers the error gives a line and column. Read the word at that position and the one before it: it is usually a keyword Oracle does not allow there, not a bracket.

Count the brackets and reduce the statement

Format the statement so each nested level is indented (the site's SQL formatter helps), check that every "(" has a matching ")", then remove clauses one at a time until the error disappears. The last part you removed contains the problem.

Compare a working definition from the dictionary

For a CREATE TABLE copied from another system, check how Oracle expects similar columns to be defined by looking at an existing table.

SELECT column_name, data_type, data_length, data_precision, nullable, identity_column
FROM user_tab_columns
WHERE table_name = 'CUSTOMERS'
ORDER BY column_id;
What to look for

Oracle data types and identity settings for a table that already works, to copy from.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Use Oracle syntax for auto-numbered columns

Changes schema

Oracle has no AUTO_INCREMENT keyword. Use an identity column (Oracle Database 12c and later) or a sequence default.

CREATE TABLE shop.customers (
    id    NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    email VARCHAR2(200) NOT NULL
);

Remove ORDER BY from the subquery

Read-only

The order of rows inside an IN subquery has no meaning. Remove it, and sort the outer query if you need ordered results. If you need "the latest N rows" inside the subquery, use FETCH FIRST in an inline view instead.

SELECT c.id, c.email
FROM shop.customers c
WHERE c.id IN (SELECT o.customer_id FROM shop.orders o WHERE o.order_date >= DATE '2026-01-01')
ORDER BY c.email;

Fix the bracket or comma Oracle is pointing at

Read-only

When the problem really is punctuation, add the missing ")" or the missing comma between definitions. Writing one column or constraint per line makes both easy to see.

SELECT order_id, ROUND(SUM(quantity * unit_price), 2) AS total
FROM shop.order_lines
GROUP BY order_id;

Examples

AUTO_INCREMENT copied from a MySQL script

Not reproduced here: no Oracle Database is installed for this site. The message text comes from Oracle's error reference, whose cause includes unrecognised information inside the parentheses; Oracle's CREATE TABLE syntax has no AUTO_INCREMENT keyword. The exact position Oracle reports is illustrative.

CREATE TABLE customers (
    id NUMBER PRIMARY KEY AUTO_INCREMENT,
    email VARCHAR2(200)
);
Expected result (documented format, not run)
ORA-00907: missing right parenthesis

ORDER BY inside an IN subquery

Not reproduced here: no Oracle Database is installed for this site. The message text comes from Oracle's error reference. The brackets are balanced; the parser stops at ORDER BY because it does not accept it in this subquery, and reports the parenthesis it expected instead.

SELECT id, email
FROM customers
WHERE id IN (SELECT customer_id FROM orders ORDER BY order_date);
Expected result (documented format, not run)
ORA-00907: missing right parenthesis

A missing comma between column definitions

Not reproduced here: no Oracle Database is installed for this site. The message text comes from Oracle's error reference; without the comma after PRIMARY KEY, customer_id is read as unexpected information in the column list. A different statement shape can make Oracle report another syntax error for the same mistake.

CREATE TABLE orders (
    id          NUMBER PRIMARY KEY
    customer_id NUMBER NOT NULL,
    order_date  DATE
);
Expected result (documented format, not run)
ORA-00907: missing right parenthesis

How to prevent it

When moving DDL from MySQL, SQL Server or PostgreSQL, convert it to Oracle syntax rather than running it as it is: identity columns instead of AUTO_INCREMENT or IDENTITY(1,1), VARCHAR2 and NUMBER types, and no UNSIGNED. Keep one column or constraint per line so a missing comma is visible.

Format long queries with one level of nesting per indent, and sort only in the outermost query. A formatter or an editor that highlights matching brackets catches most of these errors before they reach the database.

Common questions

How do I fix ORA-00907 missing right parenthesis?

Look at the token Oracle marks. If a bracket is missing, add it; more often there is a word Oracle does not accept inside the brackets, such as AUTO_INCREMENT in CREATE TABLE or ORDER BY in an IN subquery. Remove or replace it with Oracle syntax.

Why does Oracle say a parenthesis is missing when they all match?

Oracle's reference lists unrecognised information inside the parentheses as a cause. The parser stops at the unexpected word and reports the closing bracket it expected there, so the real problem is that word.

Can I use ORDER BY in a subquery in Oracle?

Not in a subquery used with IN or a comparison, where it raises ORA-00907. Sort the outer query instead, or use an inline view in the FROM clause with FETCH FIRST when you need the top rows.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on Oracle Database Error Messages reference (26ai, 21c and 19c); not run locally. Messages and explanations follow Oracle's Database Error Messages reference; no Oracle Database was available, so the examples were not run locally.

Still stuck on an Oracle error?

Browse the full Oracle error library, or get hands-on help from an experienced SQL professional.