Question:
-
How can I (programmatically) obtain a complete list of reserved keywords in Sybase?
Specifically, ones that can not be a column name in a table.
-
Alternately, how can I check whether a specific identifier is a reserved keyword in Sybase?
Background:
I have a process which takes a comma separated file with headers and loads into a temp table in Sybase.
The goal is to have the temp table column names match the file column names.
This will fail if the file has a column named after a reserved keyword.
I’d like to catch that scenario BEFORE the CREATE TABLE statement fails.
Notes:
-
I am looking for a Sybase-version-independent solution.
Therefore “copy all the words in Sybase Reference Manual (e.g. this for v.12.5) is NOT a valid answer. I’m perfectly aware I can do that. But it will not work in Sybase 15 without changing the keyword list by hand.
-
If the solution exists but not available in earlier Sybase versions, I need something compatible with Sybase 12.5 and later
-
I’m also perfectly aware of how to do this by creating a table with any words I have, trapping
CREATE TABLEfailure, and reading which word failed. I’m looking for a more elegant solution if available.
First, turn on “quoted_identifier” in your config (set quoted_identifier on). Then escape all your column names with double quotes.
That way you don’t need to catch which ones are reserved words, and all columns will have the names you expect them to have.