dbTalk Databases Forums  

Query to work out creation order of Database segments, so as to create indentical copy of db?

comp.databases.sybase comp.databases.sybase


Discuss Query to work out creation order of Database segments, so as to create indentical copy of db? in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Brehony
 
Posts: n/a

Default Query to work out creation order of Database segments, so as to create indentical copy of db? - 12-12-2003 , 07:32 AM






I have recently taken over responsibility for a Sybase database that
has been in use for over 6 years. I am not a trainined Db admin,
although I do know soemthing about it, which is why I ended up looking
after this system. In the land of the blind...

No-one who had anything to do with the database over the years, still
works for the company. The database looks like it was grown as needed,
without any long term plan or procedure.

I would like to deal with setting up a backup copy of this Database on
another Unix box. My question is this, is there a system query that
will tell me the order in which the database in question was initially
created, and the order in which segments (data and log) were added to
it?

To double check, for a database to be able to load a dump from another
database, it must have been created in the same order and size on the
same Sybase device names, correct?

Any advice would be appreciated! Thanks.

Tom.

Reply With Quote
  #2  
Old   
L. Bertolini
 
Posts: n/a

Default Re: Query to work out creation order of Database segments, so as to create indentical copy of db? - 12-12-2003 , 08:17 AM






Try this sql:

select 'dbname'=db_name(dbid), dbid, d.name,
segmap, 'system'=segmap&1, 'default'=segmap&2, 'log'=segmap&4,
u.lstart, size, mb=size/512,
vstart, 'vdevno'= case
when d.low/16777216<0 then 256 + d.low/16777216
else d.low/16777216
end
from master.dbo.sysdevices d,
master.dbo.sysusages u
where d.cntrltype=0
and u.vstart >= d.low
and u.vstart <= d.high
order by 1, u.lstart


This will map out the database fragments in order.
If the fragment contains the "system" segment, column "system" will be 1.
If the fragment contains the "default" segment, column "default" will be 2.
If the fragment contains the "log" segment, column "log" will be 4.
If segmap > 7, the fragment contains some other, user-defined segment.

Tom Brehony wrote:

Quote:
I have recently taken over responsibility for a Sybase database that
has been in use for over 6 years. I am not a trainined Db admin,
although I do know soemthing about it, which is why I ended up looking
after this system. In the land of the blind...

No-one who had anything to do with the database over the years, still
works for the company. The database looks like it was grown as needed,
without any long term plan or procedure.

I would like to deal with setting up a backup copy of this Database on
another Unix box. My question is this, is there a system query that
will tell me the order in which the database in question was initially
created, and the order in which segments (data and log) were added to
it?

To double check, for a database to be able to load a dump from another
database, it must have been created in the same order and size on the
same Sybase device names, correct?

Any advice would be appreciated! Thanks.

Tom.



Reply With Quote
  #3  
Old   
Bret Halford
 
Posts: n/a

Default Re: Query to work out creation order of Database segments, so as to create indentical copy of db? - 12-12-2003 , 03:04 PM



tomb (AT) lk (DOT) blackbird.ie (Tom Brehony) wrote in message news:<5349f6b1.0312120532.1015a7fa (AT) posting (DOT) google.com>...
Quote:
I have recently taken over responsibility for a Sybase database that
has been in use for over 6 years. I am not a trainined Db admin,
although I do know soemthing about it, which is why I ended up looking
after this system. In the land of the blind...

No-one who had anything to do with the database over the years, still
works for the company. The database looks like it was grown as needed,
without any long term plan or procedure.

I would like to deal with setting up a backup copy of this Database on
another Unix box. My question is this, is there a system query that
will tell me the order in which the database in question was initially
created, and the order in which segments (data and log) were added to
it?

To double check, for a database to be able to load a dump from another
database, it must have been created in the same order and size on the
same Sybase device names, correct?

Any advice would be appreciated! Thanks.

Tom.
Hi Tom,

Your last question first: No, to be able to load a database, all that
is
necessary is that the destination be at least as large as the source
of the dump (and from the same platform, and same character
set/sortorder). The
size and order of segments of the source will be overlayed over the
order of devices you've specified for the destination - so you can
wind up with data on log devices and vice versa if they don't match
up, but it will load and be perfectly usable.

As for a script, see the sp__revdb procedure in Ed Barlow's Collection
of Procedures at http://www.isug.com/Sybase_FAQ/ASE/section9.html

-bret


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.