This article is half-done without your Comment! *** Please share your thoughts via Comment ***
You can’t create a table with the reserved keyword in PostgreSQL which is a very Common Sense.
But still, people are trying to create a table with Reserved Keywords. The reason is, they don’t know about which keywords are reserved and unreserved.
So in this post, I am sharing a script to check the list of Reserved and Unreserved keywords of PostgreSQL.
Sample table which we can’t create with reserved keyword:
1 2 3 4 5 6 7 8 9 10 |
CREATE TABLE all (ID INT); ERROR: syntax error at or near "all" LINE 2: CREATE TABLE all (ID INT); ^ ********** Error ********** ERROR: syntax error at or near "all" SQL state: 42601 Character: 15 |
Sample table which we can create with unreserved keyword:
ALTER – look like reserved keyword, but it is not.
1 |
CREATE TABLE ALTER (ID INT); |
Check all the reserved keywords:
1 2 3 |
SELECT * FROM pg_get_keywords() WHERE catdesc = 'reserved'; |
Check all the unreserved keywords:
1 2 3 |
SELECT * FROM pg_get_keywords() WHERE catdesc = 'unreserved'; |
Leave a Reply