dbTalk Databases Forums  

compare db-schema

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss compare db-schema in the sybase.public.sqlanywhere.general forum.



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

Default compare db-schema - 10-26-2009 , 04:21 AM






Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards

Reply With Quote
  #2  
Old   
Breck Carter [TeamSybase]
 
Posts: n/a

Default Re: compare db-schema - 10-26-2009 , 05:22 AM






See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Quote:
Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: compare db-schema - 10-27-2009 , 11:58 AM



thx Breck... seems to be a workable solution.

But do you have also any idea for ASA 9.
I ask because, although we begin shortly productively with SA11 but already
have many customers with ASA 9.

Ingmar

"Breck Carter [TeamSybase]" <NOSPAM__breck.carter (AT) gmail (DOT) com> schrieb im
Newsbeitrag news:7h1be55ginhk78kr8gr5mcle0e3tfrk73r (AT) 4ax (DOT) com...
Quote:
See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any
changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards


--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

Reply With Quote
  #4  
Old   
Volker Barth
 
Posts: n/a

Default Re: compare db-schema - 10-28-2009 , 03:23 AM



Ingmar,

DUNLOAD -no was introduced with SA 11 whereas older ASA/SA versions just
have the -n option. Therefore with ASA9, the UNLOAD -n output of the
particular groups of DB objects will not be ordered by name but by
creation date. That *may* make the comparing a bit more difficult if the
creation order is different in different dbs.

Besides that, Breck's description should work with older versions, too -
you just have to adapt the path names.


OTOH, if you just want to make sure, you added the correct columns to a
few tables, you can also just write some SQL queries against the system
tables and compare that output, i.e. something like

select st.table_name, sc.column_name, sc.nulls, sc."check",
sc."default", sd.domain_name, sut.type_name
from (syscolumn sc key join systable st key join sysdomain sd) left join
sysusertype sut on sc.user_type = sut.type_id
where table_name in ('MyTable1', 'MyTable2', 'MyTable3')
order by table_name, column_name;
output to 'Update_Check\ColCheckList.txt';

When doing updates in our replication setup, I frequently use queries
like this to check if consolidated and remotes have the exact same
schema before and after a schema update.
It may be more more focussed on the objects where differences are expected.


HTH
Volker


Ingmar wrote:
Quote:
thx Breck... seems to be a workable solution.

But do you have also any idea for ASA 9.
I ask because, although we begin shortly productively with SA11 but already
have many customers with ASA 9.

Ingmar

"Breck Carter [TeamSybase]" <NOSPAM__breck.carter (AT) gmail (DOT) com> schrieb im
Newsbeitrag news:7h1be55ginhk78kr8gr5mcle0e3tfrk73r (AT) 4ax (DOT) com...
See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any
changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com


Reply With Quote
  #5  
Old   
 
Posts: n/a

Default Re: compare db-schema - generate update-script - 10-28-2009 , 04:09 AM



thx Volker... good idea.

Ok... now have a further question...
Is there a built-in function or another way to generate a SQL script based
on the differences between DB-01 and DB-02? That is, I have had 2
databases,schemas, phy/log-db-modells etc. and looking for a way to generate
automatically a SQL script, which can update the DB-01 (may be with
PowerDesigner?).
With this script, then I want update all customer databases of type
DB-schema-01 to the schema of the DB02.

Ingmar

"Volker Barth" <No_VBarth (AT) Spam_GLOBAL-FINANZ (DOT) de> schrieb im Newsbeitrag
news:4ae80dae$1 (AT) forums-1-dub (DOT) ..
Quote:
Ingmar,

DUNLOAD -no was introduced with SA 11 whereas older ASA/SA versions just
have the -n option. Therefore with ASA9, the UNLOAD -n output of the
particular groups of DB objects will not be ordered by name but by
creation date. That *may* make the comparing a bit more difficult if the
creation order is different in different dbs.

Besides that, Breck's description should work with older versions, too -
you just have to adapt the path names.


OTOH, if you just want to make sure, you added the correct columns to a
few tables, you can also just write some SQL queries against the system
tables and compare that output, i.e. something like

select st.table_name, sc.column_name, sc.nulls, sc."check", sc."default",
sd.domain_name, sut.type_name
from (syscolumn sc key join systable st key join sysdomain sd) left join
sysusertype sut on sc.user_type = sut.type_id
where table_name in ('MyTable1', 'MyTable2', 'MyTable3')
order by table_name, column_name;
output to 'Update_Check\ColCheckList.txt';

When doing updates in our replication setup, I frequently use queries like
this to check if consolidated and remotes have the exact same schema
before and after a schema update.
It may be more more focussed on the objects where differences are
expected.


HTH
Volker


Ingmar wrote:
thx Breck... seems to be a workable solution.

But do you have also any idea for ASA 9.
I ask because, although we begin shortly productively with SA11 but
already have many customers with ASA 9.

Ingmar

"Breck Carter [TeamSybase]" <NOSPAM__breck.carter (AT) gmail (DOT) com> schrieb im
Newsbeitrag news:7h1be55ginhk78kr8gr5mcle0e3tfrk73r (AT) 4ax (DOT) com...
See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any
changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

Reply With Quote
  #6  
Old   
R. Pods
 
Posts: n/a

Default Re: compare db-schema - generate update-script - 10-28-2009 , 07:18 AM



Ingmar,

with PowerDesigner you could reverse engineer an existing database and
save the model. Do the same thing with the second database und use one
of the models as archive model for the Database -> Modify Database
function on the other model (depending on which is your "master").

It generates a script to update the structure according to the
differences (or modifies the target database directly, if you really
want). It might be necessary to modify the script manually, we do this
mostly to change the order of the generated DDL commands. But we use
that method for all our releases.

HTH
Reimer


Ingmar wrote:
Quote:
thx Volker... good idea.

Ok... now have a further question...
Is there a built-in function or another way to generate a SQL script based
on the differences between DB-01 and DB-02? That is, I have had 2
databases,schemas, phy/log-db-modells etc. and looking for a way to generate
automatically a SQL script, which can update the DB-01 (may be with
PowerDesigner?).
With this script, then I want update all customer databases of type
DB-schema-01 to the schema of the DB02.

Ingmar

"Volker Barth" <No_VBarth (AT) Spam_GLOBAL-FINANZ (DOT) de> schrieb im Newsbeitrag
news:4ae80dae$1 (AT) forums-1-dub (DOT) ..
Ingmar,

DUNLOAD -no was introduced with SA 11 whereas older ASA/SA versions just
have the -n option. Therefore with ASA9, the UNLOAD -n output of the
particular groups of DB objects will not be ordered by name but by
creation date. That *may* make the comparing a bit more difficult if the
creation order is different in different dbs.

Besides that, Breck's description should work with older versions, too -
you just have to adapt the path names.


OTOH, if you just want to make sure, you added the correct columns to a
few tables, you can also just write some SQL queries against the system
tables and compare that output, i.e. something like

select st.table_name, sc.column_name, sc.nulls, sc."check", sc."default",
sd.domain_name, sut.type_name
from (syscolumn sc key join systable st key join sysdomain sd) left join
sysusertype sut on sc.user_type = sut.type_id
where table_name in ('MyTable1', 'MyTable2', 'MyTable3')
order by table_name, column_name;
output to 'Update_Check\ColCheckList.txt';

When doing updates in our replication setup, I frequently use queries like
this to check if consolidated and remotes have the exact same schema
before and after a schema update.
It may be more more focussed on the objects where differences are
expected.


HTH
Volker


Ingmar wrote:
thx Breck... seems to be a workable solution.

But do you have also any idea for ASA 9.
I ask because, although we begin shortly productively with SA11 but
already have many customers with ASA 9.

Ingmar

"Breck Carter [TeamSybase]" <NOSPAM__breck.carter (AT) gmail (DOT) com> schrieb im
Newsbeitrag news:7h1be55ginhk78kr8gr5mcle0e3tfrk73r (AT) 4ax (DOT) com...
See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any
changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

Reply With Quote
  #7  
Old   
Breck Carter [TeamSybase]
 
Posts: n/a

Default Re: compare db-schema - 10-28-2009 , 08:00 AM



See the new improved blog post, and scroll down to...

Example 2: Compare Version 5.5 and 9 Database Schemas

This script is easily changed to work with two Version 9 databases,
or any combination of Version 5.5 through 9.

http://sqlanywhere.blogspot.com/2009...-improved.html

Breck

On 27 Oct 2009 09:58:52 -0800, <Ingmar> wrote:

Quote:
thx Breck... seems to be a workable solution.

But do you have also any idea for ASA 9.
I ask because, although we begin shortly productively with SA11 but already
have many customers with ASA 9.

Ingmar

"Breck Carter [TeamSybase]" <NOSPAM__breck.carter (AT) gmail (DOT) com> schrieb im
Newsbeitrag news:7h1be55ginhk78kr8gr5mcle0e3tfrk73r (AT) 4ax (DOT) com...
See
http://sqlanywhere.blogspot.com/2008...e-schemas.html

AFAIK there is no built-in schema checksum comparison.

Breck

On 26 Oct 2009 02:21:13 -0800, <Ingmar> wrote:

Hi,

is there a way to compare the schemas of two databases?
I need this after processing an update to the schema to check if any
changes
have been copied correctly.

In another database system, there was a function to create and export a
checksum for the schema (for each table). If I created a list with the
checksums for the original- and the customer-database and there was no
difference in the checksums... I knew, that everything is ok..
Is there sowas perhaps also in SA?

Regards


--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter (AT) risingroad (DOT) com

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.