Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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
Saloon Keeper
Posts: 4008
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic