DEV Community

umzzil nng
umzzil nng

Posted on • Originally published at oraerror.com

Oracle ORA-00923 Error: Causes and Solutions Complete Guide

ORA-00923: FROM Keyword Not Found Where Expected

ORA-00923 is a syntax error thrown by the Oracle SQL parser when it cannot find the FROM keyword in the expected position within a SELECT statement. This typically means the SQL statement violates Oracle's grammar rules somewhere between the SELECT and FROM clauses. It is one of the most common SQL errors encountered by both beginners and experienced developers alike.


Top 3 Causes and Fixes

1. Missing Comma Between Columns in SELECT Clause

The most frequent cause is a missing comma (,) between column names or expressions in the SELECT clause. Without the comma, the Oracle parser loses track of where one expression ends and another begins, ultimately failing to locate the FROM keyword.

-- Incorrect: Missing comma
SELECT employee_id first_name last_name
FROM employees;
-- ORA-00923: FROM keyword not found where expected

-- Correct: Commas properly placed
SELECT employee_id, first_name, last_name
FROM employees;
Enter fullscreen mode Exit fullscreen mode

Quick Fix: Always place each column on its own line during development — it makes missing commas immediately visible during code review.


2. Using Reserved Words or Spaces in Column Aliases Without Double Quotes

Oracle reserves many keywords (e.g., DATE, ORDER, SELECT, FROM, NUMBER). Using them as column aliases without enclosing them in double quotes causes the parser to misinterpret the query structure, resulting in ORA-00923. Aliases containing spaces also require double quotes — single quotes will not work.

-- Incorrect: Reserved word used as alias
SELECT salary * 12 date
FROM employees;
-- ORA-00923: FROM keyword not found where expected

-- Incorrect: Space in alias with single quotes
SELECT employee_id 'Emp ID'
FROM employees;
-- ORA-00923: FROM keyword not found where expected

-- Correct: Use double quotes for reserved words and spaces
SELECT
    salary * 12      AS "date",
    employee_id      AS "Emp ID",
    hire_date        AS "Start Date"
FROM employees;
Enter fullscreen mode Exit fullscreen mode

Quick Fix: Adopt a naming convention that avoids Oracle reserved words entirely. Use reg_date instead of date, sort_order instead of order, etc.


3. Missing FROM DUAL for Standalone Expressions

Unlike MySQL or SQL Server, Oracle (prior to version 23c) requires FROM DUAL when selecting expressions, constants, or function results that are not tied to a real table. Omitting it causes ORA-00923.

-- Incorrect: No FROM clause
SELECT SYSDATE;
-- ORA-00923: FROM keyword not found where expected

SELECT 1 + 1;
-- ORA-00923: FROM keyword not found where expected

-- Correct: Use FROM DUAL
SELECT SYSDATE AS current_time FROM DUAL;
SELECT 1 + 1   AS result      FROM DUAL;

-- Practical example: Testing functions
SELECT
    TO_CHAR(SYSDATE, 'YYYY-MM-DD')  AS today,
    ADD_MONTHS(SYSDATE, 6)          AS six_months_later,
    NVL(NULL, 'default')            AS nvl_test
FROM DUAL;
Enter fullscreen mode Exit fullscreen mode

Note: Oracle 23c (23ai) introduced the ability to omit FROM DUAL for simple expressions. However, for backward compatibility across older environments, always include FROM DUAL in production code.


Prevention Tips

  1. Use an Oracle-aware IDE: Tools like SQL Developer, DBeaver, or Toad parse your SQL in real time and highlight syntax errors before execution. Enable the SQL formatter to keep code consistently structured — this alone catches most missing-comma issues instantly.

  2. Establish a team naming convention: Document a list of Oracle reserved words and enforce alias/column naming rules that avoid them entirely. Include Oracle's official reserved words list in your team's development guidelines so every developer — junior or senior — can reference it easily.


Related Oracle Errors

  • ORA-00936Missing expression: Occurs when an expression is incomplete, often a comma with nothing following it.
  • ORA-00942Table or view does not exist: The FROM clause is syntactically correct, but the referenced object is missing or inaccessible.
  • ORA-00907Missing right parenthesis: Unmatched parentheses in subqueries; sometimes confused with ORA-00923 in complex SQL.
  • ORA-00900Invalid SQL statement: A broader syntax error when Oracle cannot recognize the statement type at all.

📖 Want a more detailed guide?
Check out the full in-depth version (Korean) on oraerror.com — includes detailed analysis, additional SQL examples, and prevention tips.

Top comments (0)