SQL parser library for Java - Retrieve the list of table names present in a SQL statement

后端 未结 4 977
Happy的楠姐
Happy的楠姐 2020-12-18 09:20

I am looking for a SQL Library that will parse an SQL statement and return some sort of Object representation of the SQL statement. My main objective is actually to be able

4条回答
  •  忘掉有多难
    2020-12-18 09:57

    I doubt you'll find anything prewritten that you can just use. The problem is that ISO/ANSI SQL is a very complicated grammar — something like more than 600 production rules IIRC.

    Terence Parr's ANTLR parser generator (Java, but can generate parsers in any one of a number of target languages) has several SQL grammars available, including a couple for PL/SQL, one for a SQL Server SELECT statement, one for mySQL, and one for ISO SQL.

    No idea how complete/correct/up-to-date they are.

    http://www.antlr.org/grammar/list

提交回复
热议问题