You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Tim McConnell <ti...@gmail.com> on 2009/05/09 03:59:09 UTC

Valid table/column names

Hi, I'm wondering if anyone recalls the rationale for making table and/or column 
names valid by appending number(s) to the end of the name (i.e., DATE --> DATE0, 
TIME--> TIME1) ??  I ask for a number of reasons. Primarily I'm just trying to 
understand, but many of the SLQ92 reserved words/keys in the sql-keywords.rscs 
file can be, and are used, as valid column names. For example, NAME, VALUE, and 
NUMBER are SQL92 reserved keywords, but they're frequently used as valid column 
names without being converted to NAME0, VALUE0, or NUMBER0.

So, this mechanism for creating valid column names by appending numbers when 
reserved keywords are involved doesn't seem to be uniformly applied, or at least 
it's not obvious to me. Finally, many of the major database products (e.g., DB2, 
Oracle) support the usage of reserved keywords if they are explicitly enclosed in 
double quotes (e.g., "TIMESTAMP", "DATE", "TIME"). I wonder if it might be more 
intuitive and less problematic to utilize this technique when the database 
supports it ??

-- 
Thanks,
Tim McConnell

Re: Valid table/column names

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Tim,

Yes, if quoting is legal, then my preferred solution is that quoting  
reserved word names should be the default treatment.

Craig

On May 8, 2009, at 6:59 PM, Tim McConnell wrote:

> Hi, I'm wondering if anyone recalls the rationale for making table  
> and/or column names valid by appending number(s) to the end of the  
> name (i.e., DATE --> DATE0, TIME--> TIME1) ??  I ask for a number of  
> reasons. Primarily I'm just trying to understand, but many of the  
> SLQ92 reserved words/keys in the sql-keywords.rscs file can be, and  
> are used, as valid column names. For example, NAME, VALUE, and  
> NUMBER are SQL92 reserved keywords, but they're frequently used as  
> valid column names without being converted to NAME0, VALUE0, or  
> NUMBER0.
>
> So, this mechanism for creating valid column names by appending  
> numbers when reserved keywords are involved doesn't seem to be  
> uniformly applied, or at least it's not obvious to me. Finally, many  
> of the major database products (e.g., DB2, Oracle) support the usage  
> of reserved keywords if they are explicitly enclosed in double  
> quotes (e.g., "TIMESTAMP", "DATE", "TIME"). I wonder if it might be  
> more intuitive and less problematic to utilize this technique when  
> the database supports it ??
>
> -- 
> Thanks,
> Tim McConnell

Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!