views:

1974

answers:

5

I'm looking for a command line tool to generate DDL for both tables and indexes (nothing more complicated is needed) for some sybase tables in databases I take care of. I have access to gui tools for viewing at individual DDLs, and I could cut and paste them, but I want something that will go through all the tables in a datbase and generate some nice text files that I can get checked into cvs.

I tried using a tool called ddlgen, which was provided by Sybase, but it just threw exceptions like: bash-3.00# ./ddlgen -SdatabaseServer:4100 -Uusername -PsecretPassword -TDB -NdatabaseName U64: null: databaseName.dbo.firstTable U64: null: databaseName.dbo.firstTable at com.sybase.ddlgen.container.UserTableContainer.getDependentDDL(UserTableContainer.java:1065) at com.sybase.ddlgen.container.UserTableContainer.open(UserTableContainer.java:1364) at com.sybase.ddlgen.container.UserTableMetaContainer.open(UserTableMetaContainer.java:94) at com.sybase.ddlgen.container.DDLBaseContainer.load(DDLBaseContainer.java:76) at com.sybase.ddlgen.container.DatabaseContainer.addChildren(DatabaseContainer.java:552) at com.sybase.ddlgen.container.DatabaseContainer.open(DatabaseContainer.java:104) at com.sybase.ddlgen.container.DatabaseMetaContainer.open(DatabaseMetaContainer.java:114) at com.sybase.ddlgen.DDLThread.run(DDLThread.java:89)

which wasn't very helpful. I keep thinking that there must be a nice perlish way to do this, but I don't know what. it is.

...thanks

A: 

Download an evaluation version of Embarcadero DBArtisan and use its extract feature to get the DDL out.

You can turn Logging on in DBArtisan (Logfile ->Log SQL) and then see what SQL it's sending to Sybase to get the table DDL. Copy and paste the SQL in the logfile to a script that you run from the command line and that might work.

Apologies in advance if you are not using Windows...DBArtisan is Windows-only.

Michael Sharek
A: 

Another way of doing this is MyGeneration a code generator (like CodeSmith but open source) which uses templates to create code. That code could be anything you like - Sql, C# etc. I use Sql Server and I've used some of the freely available templates to create DDL as you specify, and automagically create NHibernate Mapping files too - brilliant.

MrTelly
A: 

ddlgen will give you what you require and works very well. You seem to be having an enviroment issue with Java. Try again and post the error that you have in it's entirety.

Vincent
+1  A: 

use below command to get deffination

defncopy -P tester1 -S sqppdb2 -U pmestr -D ppdb2 -o tab4 ppdb2..tab4

Thanks http://www.clickfreehit.com

this works, but doesn't export table ddl
stu
That link is just a spam site, no? I didn't see any content relevant to the question.
polyglot
+1  A: 

You can also use the Perl-based dbschema.pl

http://www.isug.com/Sybase_FAQ/ASE/section9.html#9.3.2

Paul Harrington
The link in the ISUG FAQ no longer works, but there is a copy of dbschema 2.4.2 here: http://www.peppler.org/downloads/dbschema-2_4_2.zip
martin clayton