Registry / database / oracle-sql-parser

oracle-sql-parser

JSON →
library0.1.0jsnpmunverified

Spec-compliant Oracle SQL parser that generates an AST following the Oracle Database Language Reference. Version 0.1.0 is the initial release, likely with sporadic updates. It supports common Oracle DDL and DML statements. Differentiators: built specifically for Oracle SQL syntax, not generic SQL, and includes an AST explorer. Currently only supports limited statements like SELECT, CREATE TABLE, INSERT; not production-ready for complex queries.

npm install oracle-sql-parser
INSTALL
IMPORT
SIG · ORACLE-SQL-PARSER
O
oracle-sql-parser
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
import { Parser } from 'oracle-sql-parser'
const oracleSqlParser = require('oracle-sql-parser'); const Parser = oracleSqlParser.Parser;
CommonJS require works, but destructure directly: const { Parser } = require('oracle-sql-parser').
parse
import { parse } from 'oracle-sql-parser'
const { Parser } = require('oracle-sql-parser'); const parser = new Parser(); const ast = parser.parse(sql);
The package exports a standalone `parse` function as well. Using Parser class is equivalent.
SqlParserError
import { SqlParserError } from 'oracle-sql-parser'
Error class for parser errors.

Parses a simple Oracle CREATE TABLE statement and logs the AST as JSON, with error handling for parse failures.

import { parse } from 'oracle-sql-parser'; const sql = 'CREATE TABLE users (id INTEGER, name VARCHAR2(100))'; try { const ast = parse(sql); console.log(JSON.stringify(ast, null, 2)); } catch (err) { console.error('Parse error:', err.message); }
Debug
Known issues
gotchaParser does not support all Oracle SQL syntax; only a subset is implemented. Complex queries may fail.
fix
Check the list of supported statements against the parser's documentation or source.
affects: >=0.1.0
gotchaThe parser is not streaming; entire SQL string must be passed at once. Large scripts may cause memory issues.
fix
Split large SQL scripts into individual statements and parse separately.
affects: >=0.1.0
breakingVersion 0.1.0: Initial release; API may change without notice in future minor versions.
fix
Pin to exact version and test upgrades.
affects: 0.1.0
deprecatedNo deprecations yet in this early version.
affects: >=0.1.0
gotchaParser uses its own AST node types; not compatible with other SQL parser ASTs (e.g., sqlite-parser, pg-query-native).
fix
Transform the AST if needed for interoperability.
affects: >=0.1.0
gotchaNo TypeScript types shipped; users must create own type definitions.
fix
Add a types.d.ts file or use jotai for custom types.
affects: >=0.1.0
gotchaParser does not handle Oracle-specific syntax like hierarchical queries, flashback, or advanced analytics.
fix
Expect parse errors for unsupported syntax; consider alternative parsers for advanced features.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Unexpected token at line 1 column 10
The SQL contains unsupported syntax or malformed statements.
fix
Simplify the SQL to basic SQL; check the parser's supported statements list.
TypeError: parser.parse is not a function
Incorrect import — forgot to instantiate Parser class.
fix
Correct usage: const parser = new Parser(); then parser.parse(sql);
Cannot find module 'oracle-sql-parser'
Package not installed or incorrect installation path.
fix
Run `npm install oracle-sql-parser` and ensure node_modules is correct.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources