If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > change schema name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-08, 12:23
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
change schema name

we need to change schema name of some tables on one of our databases (DB2 UDB on UNIX).

The only way I could think of is:

- export data from tables which should be changed
- drop those tables
- create new schema
- create tables with new schema
- create indexes with new schema
- import data to tables.

Is there any other way (shorter, easier, faster) to do it?
Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 12-04-08, 12:42
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
That is the way to do it. Although if you fully qualify the table names on the create table statements, you do not have to create the schema explicitly.

Andy
Reply With Quote
  #3 (permalink)  
Old 12-04-08, 12:53
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
How about "CREATE ALIAS NEWSCHEMA.TABLENAME FOR OLDSCHEMA.TABLENAME"?
Reply With Quote
  #4 (permalink)  
Old 12-04-08, 22:09
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
There is an administrative stored procedure (included with DB2) that will change the schema name for entire database, but I don't recall if you can specify indvidual tables. I have used it in DB2 9.5, and it works well except that you have reset any identity columns and sequences yourself, since they get reset to 1. I forgot the name of the SP, but if you look around you should be able to find it,
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 12-05-08, 09:41
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Yes, found it - it is ADMIN_COPY_SCHEMA - moves data between schemas within same DB. It looks perfect for my task but it is not present in v8.2 (only dbmove - moves data between databases).

Any ideas on how I can use db2move in my case?

Thanks in advance
Reply With Quote
  #6 (permalink)  
Old 12-05-08, 12:31
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by MarkhamDBA

Any ideas on how I can use db2move in my case?
You will just need to edit db2move.lst to replace the schema name in between "db2move ... export" and "db2move ... load"
Reply With Quote
  #7 (permalink)  
Old 12-05-08, 12:35
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
the problem in this case is that database name will change - i am moving data from one db to another. The original task was to re-name schema.
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #8 (permalink)  
Old 12-05-08, 13:21
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Why do you think it is a problem?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On