为Sybase表和索引生成DDL

时间:2021-12-02 07:28:10

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 that I take care of. I have access to GUI tools for viewing the individual DDLs, and I could cut and paste them, but I would like something that will go through all the tables in a database and generate some nice text files that I can get checked into CVS.

我正在寻找一个命令行工具来为我负责的数据库中的某些Sybase表生成表和索引的DDL(不需要复杂)。我可以访问用于查看各个DDL的GUI工具,我可以剪切和粘贴它们,但是我希望能够通过数据库中的所有表格生成一些可以检入CVS的文本文件。

I tried using a tool called ddlgen, which was provided by Sybase, but it just threw exceptions like this:

我尝试使用一个名为ddlgen的工具,它由Sybase提供,但它只是抛出了这样的异常:

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 that would be.

这不是很有帮助。我一直认为必须有一个很好的Perlish方法来做到这一点,但我不知道那会是什么。

5 个解决方案

#1


You can also use the Perl-based dbschema.pl

您还可以使用基于Perl的dbschema.pl

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

#2


use below command to get deffination

使用下面的命令来获得deffination

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

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

Thanks

#3


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

下载Embarcadero DBArtisan的评估版并使用其提取功能来获取DDL。

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.

您可以在DBArtisan(日志文件 - >日志SQL)中打开日志记录,然后查看它向Sybase发送的SQL以获取表DDL。将日志文件中的SQL复制并粘贴到您从命令行运行的脚本,该脚本可能有效。

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

如果您不使用Windows,请提前道歉... DBArtisan仅限Windows。

#4


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.

另一种方法是使用MyGeneration代码生成器(如CodeSmith但开源),它使用模板创建代码。那段代码可以是你喜欢的任何东西--Sql,C#等我使用Sql Server并且我已经使用了一些免费提供的模板来创建你指定的DDL,并且自动创建NHibernate Mapping文件太棒了。

#5


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.

ddlgen将为您提供您所需要的并且运作良好。您似乎遇到了Java的环境问题。再试一次,然后发布完整的错误。

#1


You can also use the Perl-based dbschema.pl

您还可以使用基于Perl的dbschema.pl

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

#2


use below command to get deffination

使用下面的命令来获得deffination

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

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

Thanks

#3


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

下载Embarcadero DBArtisan的评估版并使用其提取功能来获取DDL。

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.

您可以在DBArtisan(日志文件 - >日志SQL)中打开日志记录,然后查看它向Sybase发送的SQL以获取表DDL。将日志文件中的SQL复制并粘贴到您从命令行运行的脚本,该脚本可能有效。

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

如果您不使用Windows,请提前道歉... DBArtisan仅限Windows。

#4


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.

另一种方法是使用MyGeneration代码生成器(如CodeSmith但开源),它使用模板创建代码。那段代码可以是你喜欢的任何东西--Sql,C#等我使用Sql Server并且我已经使用了一些免费提供的模板来创建你指定的DDL,并且自动创建NHibernate Mapping文件太棒了。

#5


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.

ddlgen将为您提供您所需要的并且运作良好。您似乎遇到了Java的环境问题。再试一次,然后发布完整的错误。