parser

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2021 License: Apache-2.0 Imports: 8 Imported by: 1

README

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
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIdentGroupToken

func AddIdentGroupToken(action lexmachine.Action, rss ...string)

func AddIdentToken

func AddIdentToken(rs string, action lexmachine.Action)

func AddTokenBetween

func AddTokenBetween(left []byte, right []byte, matchEnd bool, action lexmachine.Action)

func NewLexer

func NewLexer(s string) (*yyLexImpl, error)

func Parser

func Parser(query string) ([]ast.Node, error)

Types

This section is empty.

Directories

Path Synopsis
ast

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL