惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
罗磊的独立博客
C
Check Point Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
B
Blog RSS Feed

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Oracle ORA-00911 Error: Causes and Solutions Complete Guide
umzzil nng · 2026-06-16 · via DEV Community

umzzil nng

ORA-00911: Invalid Character — Causes, Fixes & Prevention

ORA-00911 is one of Oracle's most commonly encountered errors, triggered when a SQL statement contains a character that Oracle's SQL parser does not recognize as valid. This typically happens when illegal characters such as semicolons, invisible Unicode characters, or full-width special characters are present in the SQL string. Understanding the root cause quickly can save significant debugging time in production environments.


Top 3 Causes & SQL Examples

1. Trailing Semicolon in Application Code

The most frequent cause of ORA-00911 is including a semicolon (;) at the end of a SQL statement when executing it through a database driver such as JDBC, cx_Oracle, or ODP.NET. While SQL*Plus and SQL Developer use the semicolon as a statement terminator, database drivers treat it as part of the SQL string itself, causing the parser to fail.

Incorrect (causes ORA-00911):

-- This will fail when executed via JDBC or cx_Oracle
SELECT employee_id, first_name, salary
FROM employees
WHERE department_id = 50;

Correct (remove the semicolon):

-- No semicolon at the end when using a DB driver
SELECT employee_id, first_name, salary
FROM employees
WHERE department_id = 50

Note: PL/SQL blocks (BEGIN...END;) are an exception and may require semicolons depending on the driver. Always check your specific driver documentation.


2. Invisible or Non-ASCII Characters in SQL

When SQL is copied from word processors, web browsers, email clients, or markdown editors, invisible Unicode characters (e.g., non-breaking space \u00A0, line separator \u2028, or BOM characters) can silently embed themselves into the SQL string. These characters are invisible to the human eye but are immediately flagged by Oracle's parser.

Detecting hidden characters using DUMP:

-- Use DUMP to inspect character codes in a string
SELECT DUMP('SELECT * FROM dual', 16) AS char_codes
FROM dual;

-- Remove non-printable and non-ASCII characters using REGEXP_REPLACE
SELECT REGEXP_REPLACE(
           :sql_input,
           '[^\x09\x0A\x0D\x20-\x7E]',  -- Keep tab, newline, CR, and printable ASCII
           ''
       ) AS cleaned_sql
FROM dual;

Always paste SQL into a plain text editor (e.g., Notepad, VSCode with plain text mode) to strip hidden formatting before using it in your application.


3. Full-Width or Invalid Special Characters

In environments where input method editors (IMEs) are used — particularly for East Asian languages — it is easy to accidentally insert full-width characters (e.g., instead of ,, or " instead of ") into SQL statements. Oracle's parser does not accept these characters and immediately raises ORA-00911.

Incorrect (full-width comma — causes ORA-00911):

-- Full-width comma and quotation marks will break parsing
SELECT employee_idfirst_namelast_name
FROM employees;

Correct (standard ASCII punctuation):

-- Use standard half-width ASCII characters only
SELECT employee_id, first_name, last_name
FROM employees;

-- Column aliases with spaces must use standard double quotes
SELECT
    employee_id  AS "Employee ID",
    first_name   AS "First Name",
    hire_date    AS "Hire Date"
FROM employees
WHERE ROWNUM <= 5;


Quick Fix Solutions

Symptom Fix
SQL works in SQL*Plus but fails in app Remove trailing semicolon
SQL copied from browser/email fails Strip non-ASCII chars with REGEXP_REPLACE
Error after typing SQL with IME enabled Replace all punctuation with ASCII equivalents

A simple PL/SQL utility to sanitize SQL strings before execution:

CREATE OR REPLACE FUNCTION clean_sql(p_sql IN VARCHAR2)
RETURN VARCHAR2
IS
    v_sql VARCHAR2(32767);
BEGIN
    v_sql := TRIM(p_sql);
    -- Remove trailing semicolon
    IF SUBSTR(v_sql, -1) = ';' THEN
        v_sql := SUBSTR(v_sql, 1, LENGTH(v_sql) - 1);
    END IF;
    -- Strip non-ASCII characters (preserve tab, newline, carriage return)
    v_sql := REGEXP_REPLACE(v_sql, '[^\x09\x0A\x0D\x20-\x7E]', '');
    RETURN TRIM(v_sql);
END clean_sql;
/

-- Test the function
SELECT clean_sql('SELECT * FROM employees;') AS result FROM dual;


Prevention Tips

1. Enforce a No-Semicolon Policy in Application SQL
Establish a team coding standard that prohibits trailing semicolons in SQL strings passed to database drivers. Integrate a SQL linter (e.g., SQLFluff) into your CI/CD pipeline to automatically catch these issues before deployment.

2. Always Use Plain-Text Editors for SQL Authoring
Never write or paste SQL directly from rich-text sources. Use editors configured to save files as UTF-8 without BOM, and leverage the "Paste as Plain Text" option (Ctrl+Shift+V) to avoid embedding invisible formatting characters.


Related Oracle Errors

  • ORA-00900 — Invalid SQL statement (general syntax failure)
  • ORA-01756 — Quoted string not properly terminated (mismatched quotes)
  • ORA-00907 — Missing right parenthesis (bracket mismatch)
  • ORA-00936 — Missing expression (incomplete SQL structure)

📖 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.