Getting the schema for a DB table

Thomas Klausner domm at cpan.org
Sun May 25 18:38:54 BST 2014


Hi!

On Sun, May 25, 2014 at 05:46:45PM +0100, Simon Wistow wrote:
 
> Alternatively - what I'm really trying to do is get a unique finger 
> print for the schema of a database. My current plan is hashing the 
> CREATE TABLE statement but other methods would be gratefully received.

If you want a hash of the current DB schema, take a look at 
DBIx::SchemaChecksum
https://metacpan.org/pod/DBIx::SchemaChecksum

We use it to automate DB updates (but this will only work for DBs which 
can create tables inside a transcation, i.e. Postgres and sqlite, but 
neither Oracle nor MySQL).

It also comes with a script, which you could use like this to get the 
checksum:
scs.pl checksum --dsn dbi:Pg:dbname=your_db

To show the data on which the checksum is based:
scs.pl checksum --dsn dbi:Pg:dbname=your_db --show_dum

Not sure if this is what you're after, but I hope it helps..

Greetings,
domm

-- 
#!/usr/bin/perl                              http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


More information about the london.pm mailing list