github.com/sjjian/oracle_sql_parser

this is a yacc (goyacc) oracle sql parser.


Keywords
ast, goyacc, lexer, oracle, parse, parser, plsql, sql, statement, stmt, yacc
License
Apache-2.0
Install
go get github.com/sjjian/oracle_sql_parser

Documentation

Oracle SQL Parser

this is an oracle sql parser. ref: https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf

supported statement

statement sub statement yacc ast
Alter table Add column ✔️ ✔️
Alter table Modify column ✔️ ✔️
Alter table Drop column ✔️ ✔️
Alter table Rename column ✔️ ✔️
Alter table Add constraint ✔️ ✔️
Alter table Modify constraint ✔️ ✔️
Alter table Rename constraint ✔️ ✔️
Alter table Drop constraint ✔️ ✔️
Create table Relational table ✔️ ✔️
Create index Relational table ✔️
Drop table - ✔️ ✔️
Drop index - ✔️ ✔️

usage

package main

import (
	"fmt"
	"github.com/sjjian/oracle-sql-parser"
	"github.com/sjjian/oracle-sql-parser/ast"
)

func main() {
	stmts, err := parser.Parser("alter table db1.t1 add (id number, name varchar2(255))")
	if err != nil {
		fmt.Println(err)
		return
	}
	stmt := stmts[0]
	switch s := stmt.(type) {
	case *ast.AlterTableStmt:
		fmt.Println(s.TableName.Table.Value) // t1
	}
}