SQL Reserved Key Words Checker Tool
I just whipped together a tool for checking for reserved sql words. The tool checks against SQL Server 2000, MySQL 5.0, PostgreSQL 8.0, Oracle 10g, ODBC, and SQL Server Future Keywords list.
It is a good idea to make sure you db schema's will work ok across multiple db platforms, so the tool will show you which platforms a word is reserved on.
add to del.icio.us
| Tags: sql, databases, postgresql, mysql, sqlserver, oracle
Related Entries
- SQL to Select a random row from a database table - September 14, 2005
- INFORMATION_SCHEMA Support in MySQL, PostgreSQL - February 18, 2008
- Returning TOP N Records - April 18, 2003
- Top 10 Reserved SQL Keywords - October 28, 2008
- Backwards LIKE Statements - January 10, 2007
Trackbacks
Trackback Address: 290/B0B69F33B37F196AA6A89A9D3E832511
Comments
On 03/28/2005 at 8:05:45 PM EST Tim wrote:
1
This is a great idea (kind of like what you get at sqlzoo.net). If you can add DB2, that would pretty much cover all of your bases.
On 03/28/2006 at 9:44:48 AM EST Ovidiu wrote:
2
"condition" is a reserved keyword in MySQL 5.0, but this tool has found it as reserved keyword only for PgSQL 8.
On 03/28/2006 at 10:21:04 AM EST Pete Freitag wrote:
3
Thanks Ovidiu, I have updated it, I was missing a few new keywords in mysql 5.
On 07/09/2006 at 2:53:31 AM EDT Lukas wrote:
4
Hi,
just tried out your checker. I guess what it really needs is to get the information dynamically so the checker is always uptodate. That being said things like "GROUP" are probably a reserved word in any RDBMS since ages, but does not show up as reserved in all RDBMS in your checker.
On 07/09/2006 at 10:36:16 PM EDT Pete Freitag wrote:
5
Lukas, Yes that would be nice to have it dynamically updated, but hey it just a free tool.
As for GROUP not being reserved in some RDBMS's -- the way I use the tool is if a word is reserved on any RDBMS I avoid using it in my schema. Even if I'm using MySQL and it's reserved in Oracle, I like to avoid it, incase the server is ever moved to Oracle.
On 07/10/2006 at 12:48:45 AM EDT Lukas wrote:
6
Yeah, I checked "GROUP" and its not listed as reserved in MySQL, eventhough its been reserved since forever. Thats what I wanted to point out.
BTW: I am the lead author of PEAR::MDB2_Schema, which essentially is a frontend to manage a database schema in an independent format (currently the only format supported is an xml schema format). One of the cool features is that it can check the identifiers against lists of reserved words.
Anyways I will try if I can establish a standard for publishing reserved words lists in the open source database world.
On 10/29/2009 at 12:18:52 PM EDT Heikki Linnakangas wrote:
7
The keyword list for PostgreSQL is too large.
Keywords in the PostgreSQL grammar are divided into several groups, and the so-called "unreserved" keywords are actually available for use as table or column names, or in any other context as any non-keyword is. The grammar needs them as keywords because they're used in some non-ambiguous context, but for an application, there is no disinction between an unreserved keyword and a word that's not a keyword at all. For example, "CHECKPOINT" is an unreserved keyword because there's a CHECKPOINT command to perform a checkpoint, but you can create a table called CHECKPOINT or column with no problem.
An up-to-date list of keywords can be found at http://www.postgresql.org/docs/8.4/interactive/sql-keywords-appendix.html. You should ignore all the keywords listed as "non-reserved" (or blank). Even better, you could distinguish the classes of "reservedness" in the tool, but you should leave out the non-reserved ones anyway.
Post a Comment
Recent Entries
- Cache Template in Request Setting Explained
- What Version of Java is ColdFusion Using?
- ColdFusion 9 Performance Brief from Adobe
- Request Filtering in IIS 7 Howto
- J2EE Session Cookies on ColdFusion / JRun
- Hands on ColdFusion Security Training
- ColdFusion 9 Solr Vulnerability - Are you at Risk?
- FCKEditor Year 2010 Bug for Firefox 3.6 with ColdFusion
just tried out your checker. I guess what it really needs is to get the information dynamically so the checker is always uptodate. That being said things like "GROUP" are probably a reserved word in any RDBMS since ages, but does not show up as reserved in all RDBMS in your checker.
As for GROUP not being reserved in some RDBMS's -- the way I use the tool is if a word is reserved on any RDBMS I avoid using it in my schema. Even if I'm using MySQL and it's reserved in Oracle, I like to avoid it, incase the server is ever moved to Oracle.
BTW: I am the lead author of PEAR::MDB2_Schema, which essentially is a frontend to manage a database schema in an independent format (currently the only format supported is an xml schema format). One of the cool features is that it can check the identifiers against lists of reserved words.
Anyways I will try if I can establish a standard for publishing reserved words lists in the open source database world.
Keywords in the PostgreSQL grammar are divided into several groups, and the so-called "unreserved" keywords are actually available for use as table or column names, or in any other context as any non-keyword is. The grammar needs them as keywords because they're used in some non-ambiguous context, but for an application, there is no disinction between an unreserved keyword and a word that's not a keyword at all. For example, "CHECKPOINT" is an unreserved keyword because there's a CHECKPOINT command to perform a checkpoint, but you can create a table called CHECKPOINT or column with no problem.
An up-to-date list of keywords can be found at http://www.postgresql.org/docs/8.4/interactive/sql-keywords-appendix.html. You should ignore all the keywords listed as "non-reserved" (or blank). Even better, you could distinguish the classes of "reservedness" in the tool, but you should leave out the non-reserved ones anyway.







