Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Usage of Reserved words for Database Table fields

 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one more problem...
Im doing a Database Migration from HSQL to DERBy..

Some of the tables in my Source Database(HSQL) have reserved words like "USER", "CLOSE", "OPEN"...etc

When I migrate the database to DERBY which is my destination DB Im getting trouble with these reserved words... the table which have these reserved words raises exception..and the table is never created..

Any solution to check for the fields which are reserved words ?

Please let me know...

Thanks,
Sudheer.

[ August 01, 2006: Message edited by: Sudheer Yeddu ]
[ August 01, 2006: Message edited by: Sudheer Yeddu ]
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database migration is nontrivial, especially with create table statements and stored procedures. You could check online documentation for a list of reserved words. As far as converting the data, if you have a large enough set of data you might consider writing a tool that reads the exported SQL data, and does the conversion for you, else you have to do it by hand.
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sudheer Yeddu:

Some of the tables in my Source Database(HSQL) have reserved words like "USER", "CLOSE", "OPEN"...etc


Some databases allow you to use reserved words (or even mixed-case table names) by quoting the table name. For example:



I don't know enough about the DBs you're using to know if that's helpful.

Usually, if you have to create them with quotes, then you also have to reference them with quotes in your SELECT and INSERT statements.
 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies...

I also want to know whether we have any way to track the reserved words, so that I can wrap them in quotes to work after locating them..

Thanks,
Sud
 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please go thru my blog if needed, btw I have published in my blog as it may be of any help to folks doing the same...

http://taurivalor.wordpress.com/

Thanks,
Sudheer.
 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally I could do it this way..

I Put the reserved words in an array and did a check if the field name matches any one of the elements in that array.

Cheers,
Sud.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!