[FEATURE] extract primary keys from ALTER TABLE .. ADD CONSTRAINT.. . PRIMARY KEY (...); #1818
Replies: 3 comments
-
Greetings. Unfortunately I am not sure if I understand your concern correctly:
Truth is: both the In general, my very personal sentiment is: JSQLParser should be able to parse any Query and DML, while support for the various DDL is a nice to have. DDL would be much better understood by accessing the MetaData via JDBC and or the standardized Information Schemas. |
Beta Was this translation helpful? Give feedback.
-
Please have a look at the RR Diagram: https://manticore-projects.com/JSQLParser/syntax_snapshot.html#alterexpression And here is the API: https://manticore-projects.com/JSQLParser/javadoc_snapshot.html#alterexpression |
Beta Was this translation helpful? Give feedback.
-
And please don't say that this implementation is bad -- we know that :-D but did not find the resources for a proper rewrite. |
Beta Was this translation helpful? Give feedback.
-
Hi,
When parsing a CREATE TABLE, we have built-in functions to retrieve the PRIMARY KEYS in JSQLParser.
But in the case where the CREATE TABLE does not contain the PRIMARY KEYS, which are added later with an ALTER TABLE:
Done later in file:
I can't figure out how to retrieve the PRIMARY KEYS without doing manual parsing of the ALTER TABLE.
Is there a way in JSQLParser?
I have tried this attached code, but it prints null values.
PrimaryKeyExtractorTest.java.txt
(I can't in my case just move the PRIMARY KEYS creation in the staff table, because I write a schema displayer that takes in new schemas texts that I know nothing about).
Thanks,
Nicolas
Beta Was this translation helpful? Give feedback.
All reactions