为 Sybase 表和索引生成 DDL

发布于 2024-07-11 22:25:00 字数 1187 浏览 7 评论 0原文

我正在寻找一个命令行工具来为我负责的数据库中的一些 Sybase 表生成表和索引的 DDL(不需要更复杂的东西)。 我可以使用 GUI 工具来查看各个 DDL,并且可以剪切和粘贴它们,但我想要一些能够遍历数据库中所有表并生成一些不错的文本文件的东西,我可以将它们签入 CVS。

我尝试使用 Sybase 提供的名为 ddlgen 的工具,但它只是抛出如下异常:

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)

这并不是很有帮助。 我一直在想一定有一种很好的 Perlish 方式来做到这一点,但我不知道那会是什么。

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.

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

っ〆星空下的拥抱 2024-07-18 22:25:00

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

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

You can also use the Perl-based dbschema.pl

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

坦然微笑 2024-07-18 22:25:00

使用下面的命令来获取定义

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

谢谢

use below command to get deffination

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

Thanks

茶花眉 2024-07-18 22:25:00

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

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

如果您不使用 Windows,请提前致歉...DBArtisan 仅适用于 Windows。

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.

别忘他 2024-07-18 22:25:00

另一种方法是使用 MyGeneration 代码生成器(类似于 CodeSmith,但开源),它使用模板来创建代码。 该代码可以是您喜欢的任何代码 - Sql、C# 等。我使用 Sql Server,并且使用了一些免费可用的模板来根据您的指定创建 DDL,并自动创建 NHibernate 映射文件 - 太棒了。

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.

懵少女 2024-07-18 22:25:00

ddlgen 会给你你所需要的并且工作得很好。 您似乎遇到了 Java 环境问题。 再试一次并完整发布您遇到的错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文