Login Register Actian.com  

Actian Community Forum


Go Back   Actian Community Forums > Community > Questions, Feedback, and Suggestions
 

Reply
 
LinkBack Thread Tools Display Modes
Old 2012-01-30   #1 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 4
Default Creating an empty database with a different user

Hi,

I am trying to create a structural copy of a database with a different dba user. I have a number of database objects owned by different users e.g. tables and views so I havent been able to get copydb to work. I dont want the data in the database so I cant use unloaddb.

Is there a way of doing this?

Thanks,
Martin
mmannion is offline   Reply With Quote
Old 2012-01-30   #2 (permalink)
Ingres Community
 
rhann's Avatar
 
Join Date: Mar 2007
Location: roy.hann@rationalcommerce.com
Posts: 861
Blog Entries: 17
Default

Use unloaddb. It won't give you any data. It generates two scripts, one of which (copy.out) would give you the data if you were to run it. But unloaddb also generates the copy.in script with all the DDL for all the database objects. Edit it to change \nocontinue to \continue and to change the effective session IDs as appropriate for your purpose. Run it in an empty directory so all the COPY...FROM statements fail.
__________________
Roy Hann

UK Actian User Association Conference 2012 will be on Tuesday June 19, 2012. Register now.

Last edited by rhann; 2012-01-30 at 08:34 AM. Reason: Added missing "and"
rhann is offline   Reply With Quote
Old 2012-01-30   #3 (permalink)
Ingres Community
 
kschendel's Avatar
 
Join Date: Mar 2007
Location: Pittsburgh, PA
Posts: 1,662
Default

Do you want all of the variously-owned tables/views/etc in the source database to be duplicated and owned by the single alternate-user in the result database? That's what it sounds like to me.

I can't offhand think of a one-step way to do it. The simplest, assuming that the database data isn't large enough to be a problem, might be to run unloaddb and run the resulting unload.ing script. Then, edit the copy.in and take out the "set session authorization foo" statements for all of the object owners except for the ones that set the session to the original dba. Change those set-session statements to reflect the new dba. Edit the object owner names for all of the non-table objects (views, db procedures, etc) to reflect the new dba. Cat /dev/null to the copy output files for everything EXCEPT the iixxx copy files (i.e. you now have zero-length copy-in data files). Create the new database with createdb -u and run reload.ing.

If you have character-forms objects (reports, forms, etc), they can pose a challenge since the catalog entries include the owner names. Your best bet there is probably to unload the objects using forms tools such as copyform, copyapp out, etc and reload them into the new database as the new user.

Anyone have any better suggestions?
kschendel is offline   Reply With Quote

Reply


Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


© 2011 Actian Corporation. All Rights Reserved