tags:

views:

70

answers:

1

I've scanned similar questions but they seem to be referring to other databases and/or external languages.

I'm looking to programatically extract table DDL via SQL, with a result that's "good enough" to re-import and reconstruct the table.

DBArtisan produces the exact result I'm looking for, but I have a dynamic list of a few dozen tables that I need to work with, and was hoping for a programatic solution.

I figure DBArtisan has to be doing calling the API somehow. Are they just ripping against the systables or is there a system installed stored proc (similar to the one that yields stored proc text) that I'm missing?

+2  A: 

IIRC there's a tool called DBSchema ( peppler.org/downloads/dbschema-2_4_2.zip is the best URL I was able to find ) - in case the URL doesn't ring any bells, Mike Peppller is the author of sybperl. You can likely reverse engineer the code for that script if you prefer to roll your own.

As far as SQL-wise, the table info is in sysobjects table and the column info is in syscolumns in Sybase.

You can also use stored procs: http://www.razorsql.com/articles/sybase_admin_queries.html

DVK
Excellent, thanks very much. Yeah, it looks like the right solution is either dbschema itself or found within it.
Michael Wilson
@Michael - glad to help. if this was of use, please feel free to either up-vote or accept :))
DVK