Parsing SQL Statements using java

后端 未结 5 2141
礼貌的吻别
礼貌的吻别 2021-01-06 18:44

I need to parse sql statements and get column names and table names. I tried with sample code. I got table names but I am stucked to get column names for each table.

5条回答
  •  感动是毒
    2021-01-06 19:14

    You will need to create a parser for your SQL grammar. ANTLR allows to create such parsers but it can be quite difficult to create a grammar.

    Here is a list of exisiting grammar for ANTLR http://www.antlr3.org/grammar/list.html

    It contains grammar for mysql, oracle SQL that should work for you.

提交回复
热议问题