parser

package module
v0.0.0-...-2be87ae Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 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/codeindex2937/oracle-sql-parser"
	"github.com/codeindex2937/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

Overview

Code generated by goyacc -o sql.go -l sql.y. DO NOT EDIT.

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