Oracle 23.26SQLLab-verified · 2026-11-18

ORA-00911: invalid character

The SQL contains a character Oracle cannot read at that position, often from copy-paste or another database's syntax.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-00911: : invalid character after =

Jump to a cause

  1. 01Curly quotes copied from Word, email or chat
  2. 02A MySQL-style # comment
  3. 03A table name that starts with an underscore

Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-18 · container image gvenzl/oracle-free:23-slim

ORA-00911 means the SQL has a character that is not valid where it appears. In Oracle 23ai the message tells you which character and what came before it, such as ORA-00911: #: invalid character after <number>, and the * marks the spot.

The usual sources are text pasted from documents or chat, and habits from other databases. In the lab the causes were curly quotes (‘Kim’), a MySQL # comment, and a table name starting with _.

01Curly quotes copied from Word, email or chat

WHERE cust_name = ‘Kim’ uses curly quotes ‘ ’ instead of the straight '. Word processors and messengers often change quotes automatically. The message was ORA-00911: : invalid character after =: the character part is blank, but the * points right after =.

The quotes look almost the same, so it is easy to miss. Retyping them as 'Kim' returned customer 1.

Setup
Setuprun as lab_a
CREATE TABLE customers (cust_id NUMBER, cust_name VARCHAR2(20));
INSERT INTO customers VALUES (1, 'Kim');
COMMIT;
OUTPUT
Table created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT cust_id FROM customers WHERE cust_name = ‘Kim’;
✕ ERROR
SELECT cust_id FROM customers WHERE cust_name = ‘Kim’
                                                *
ERROR at line 1:
ORA-00911: : invalid character after =
Help: https://docs.oracle.com/error-help/db/ora-00911/
Checkrun as lab_a
SELECT cust_id, cust_name FROM customers;
OUTPUT
   CUST_ID CUST_NAME
---------- --------------------
         1 Kim

1 row selected.

Paste SQL into a plain text editor, or retype the quotes. Search for ‘ ’ “ ” to find them.

After the fixrun as lab_a
SELECT cust_id FROM customers WHERE cust_name = 'Kim';
✓ SUCCESS
   CUST_ID
----------
         1

1 row selected.

02A MySQL-style # comment

WHERE cust_id = 1 # VIP only uses #, which starts a comment in MySQL. Oracle does not accept it, and the error said ORA-00911: #: invalid character after <number>.

Changing it to the SQL standard comment -- VIP only made the query return Kim.

Setup
Setuprun as lab_a
CREATE TABLE customers (cust_id NUMBER, cust_name VARCHAR2(20));
INSERT INTO customers VALUES (1, 'Kim');
COMMIT;
OUTPUT
Table created.


1 row created.


Commit complete.
Reproducerun as lab_a
SELECT cust_name FROM customers WHERE cust_id = 1 # VIP only
;
✕ ERROR
SELECT cust_name FROM customers WHERE cust_id = 1 # VIP only
                                                  *
ERROR at line 1:
ORA-00911: #: invalid character after <number>
Help: https://docs.oracle.com/error-help/db/ora-00911/
Checkrun as lab_a
SELECT cust_id, cust_name FROM customers;
OUTPUT
   CUST_ID CUST_NAME
---------- --------------------
         1 Kim

1 row selected.

In Oracle use -- for one-line comments and /* */ for blocks.

After the fixrun as lab_a
SELECT cust_name FROM customers WHERE cust_id = 1 -- VIP only
;
✓ SUCCESS
CUST_NAME
--------------------
Kim

1 row selected.

03A table name that starts with an underscore

CREATE TABLE _tmp_orders failed with ORA-00911: _: invalid character after TABLE. Unquoted names in Oracle must start with a letter. The table was not created (USER_TABLES count was 0).

Renaming it to tmp_orders created the table.

Reproducerun as lab_a
CREATE TABLE _tmp_orders (order_id NUMBER);
✕ ERROR
CREATE TABLE _tmp_orders (order_id NUMBER)
             *
ERROR at line 1:
ORA-00911: _: invalid character after TABLE
Help: https://docs.oracle.com/error-help/db/ora-00911/
Checkrun as lab_a
SELECT COUNT(*) AS cnt FROM user_tables WHERE table_name = '_TMP_ORDERS';
OUTPUT
       CNT
----------
         0

1 row selected.

Start names with a letter. An underscore in the middle, like tmp_orders, is fine.

After the fixrun as lab_a
CREATE TABLE tmp_orders (order_id NUMBER);
SELECT table_name FROM user_tables WHERE table_name = 'TMP_ORDERS';
✓ SUCCESS
Table created.


TABLE_NAME
------------------------------
TMP_ORDERS

1 row selected.

FAQ

What does ORA-00911 invalid character mean?

The SQL contains a character that Oracle cannot accept at that position. The message shows the character and the word before it, and * marks the spot.

My SQL looks correct but I get ORA-00911

Check the quotes. Curly quotes ‘ ’ from Word, email or chat look almost like '. In the lab, the message even showed a blank character: ORA-00911: : invalid character after =.

Can I use # for comments in Oracle?

No. # raised ORA-00911 in the lab. Use -- or /* */.

Can an Oracle table name start with an underscore?

Not without double quotes. CREATE TABLE _tmp_orders raised ORA-00911. Start the name with a letter, like tmp_orders.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0