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 > Sybase > Copy user (schema) within same database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-20-11, 14:10
svrider svrider is offline
Registered User
 
Join Date: Jul 2002
Posts: 39
Question Copy user (schema) within same database

Hi everyone,

Is there a way to copy an entire schema, structure and data, into another within the same database.

We're testing the loading and data of a warehouse.

We're using Sybase ASE 15.

For example, we're loading into a schema called DATAMART, I want to copy it into another called DATAMART_1. That way, users can test the data in the copy while we're loading the original.

Thanks.

JFS.
Reply With Quote
  #2 (permalink)  
Old 05-23-11, 03:19
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
You can dump a database to a file, and then load that dumpfile in as many databases as you want.
1) dump database datamart to "<folder>/filename.ext"

2) load database datamart_1 from "<folder>/filename.ext"

The databases have to be of the same structure, same devicesize, etc.
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
  #3 (permalink)  
Old 05-23-11, 14:54
svrider svrider is offline
Registered User
 
Join Date: Jul 2002
Posts: 39
Quote:
Originally Posted by Martijnvs View Post
You can dump a database to a file, and then load that dumpfile in as many databases as you want.
1) dump database datamart to "<folder>/filename.ext"

2) load database datamart_1 from "<folder>/filename.ext"

The databases have to be of the same structure, same devicesize, etc.
Thanks but that's not what I'd like to do.

I want to compy a schema within the same database. Let's say I have a schema DATAMART, I want a copy called DATAMART_1 in the same environment and access it using a different user.

Doable?

Thanks.

JFS.
Reply With Quote
  #4 (permalink)  
Old 05-24-11, 05:31
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
Quote:
Originally Posted by svrider View Post
Thanks but that's not what I'd like to do.

I want to compy a schema within the same database. Let's say I have a schema DATAMART, I want a copy called DATAMART_1 in the same environment and access it using a different user.

Doable?

Thanks.

JFS.
Ah, I'm sorry, I don't know about schema's in ASE 15. I hope one of the other users here can shine a light on this...
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
  #5 (permalink)  
Old 05-25-11, 16:43
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
If I understand correct you want something like
select * into DATAMART_1.tableA from DATAMART.tableA

I don't think there is an easy way to copy all 7351 tables
Easiest way would be to create a copy of the database
Reply With Quote
  #6 (permalink)  
Old 05-26-11, 04:43
Martijnvs Martijnvs is offline
Registered User
 
Join Date: Jan 2004
Location: The Hague/Utrecht, NL
Posts: 415
He mentions 'copy a schema within the same database'. I first thought a copy between databases, but apparently he means something else.
I've never heard of schema's in Sybase...
__________________
I'm not crazy, I'm an aeroplane!
Reply With Quote
  #7 (permalink)  
Old 05-30-11, 08:42
ishu.cs ishu.cs is offline
Registered User
 
Join Date: Mar 2008
Posts: 59
Hi,

If I am not wrong from schema you means a Login that owns some objects if this is the case then the below query may be helpful for you

select 'select * into '+name +'_new_schema from '+ name from sysobjects where uid=suser_id('schema')

This will generate the sql statements to create the new tables with suffix '_new_schema' for the objects owned by the login 'schema'

execute these sql s one by one and you have the tables with the data.

Hope this will be helpful.


Ishu
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