是否可以使用 DBX 以编程方式创建数据库?

发布于 2024-07-10 18:37:51 字数 298 浏览 7 评论 0原文

看起来 TSQLConnection 只连接到现有数据库,我找不到另一个允许我向数据库服务器发送命令的组件。

我正在使用 Delphi 2009 以及 Firebird 和 MSSQL。

出现的一个想法是连接到系统数据库(例如 MSSQL 中的 master 或 tempdb),然后向服务器发送创建命令。 这可能是 MSSQL 的一个选项,但我不确定 Firebird 是否可以。

我还知道 Delphi 2009 中新的 DBX 元数据,但我找不到使用它创建数据库的方法。 我发现的所有示例都是修改现有数据库。

Looks like the TSQLConnection only connects to existing databases, and I could not find another component that allows me to send commands to the database server.

I'm using Delphi 2009 with Firebird and MSSQL.

One idea that came was to connect to a system database (master or tempdb in MSSQL for example) and then send create commands to the server. This could be an option for MSSQL, but I'm not sure for Firebird.

I'm also aware of the new DBX metadata in Delphi 2009, but I couldn't find a way to create databases using it. All examples I've found is to modify existing databases.

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

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

发布评论

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

评论(6

千纸鹤带着心事 2024-07-17 18:37:51

是的你可以。 dbExpress 现在包含一组强大的元数据类来实现这一点。

Steve Shaughnessy 在此处提供了很好的介绍。

Yes, you can. dbExpress now includes a powerful set of meta-data classes for doing just that.

Steve Shaughnessy gives a good introduction here.

深巷少女 2024-07-17 18:37:51

Erick,如果您使用 Devart 驱动程序,您可以在没有数据库名称参数的情况下进行连接并发送 t-sql 创建数据库命令。

Erick if you use Devart drivers you can connect without the databasename parameter and send the t-sql create database command.

記憶穿過時間隧道 2024-07-17 18:37:51

Delphi 中包含的 dbExpress 使用“最小公分母”策略。 通过本机驱动程序提供的查询统计信息等信息在 dbExpress 中是不可见的。 (也许我应该问这样的问题:“替代 dbExpress 实现中的哪个功能让您进行了切换?”)

dbExpress included in Delphi uses a "least common denominator" strategy. Information like query statistics which is available through native drivers is invisible with dbExpress. (Maybe I should ask a question like "Which feature in alternative dbExpress implementations made you switch?")

盗琴音 2024-07-17 18:37:51

您可以使用标准 TSQLQuery 在两个数据库上执行“CREATE DATABASE ...”。

请注意,这两者之间的语法不同。 由于 dbx 是轻量级库,因此这种 SQL 和 DB 特定操作可能永远不会得到完全支持。 它留给你 SQL。

You can execute "CREATE DATABASE ..." on both databases with standard TSQLQuery.

Note that syntax differes between these two. Since dbx is lightweight lib, this SQL and DB specific action probbably will never be fully supported. It leaves you with SQL.

萌酱 2024-07-17 18:37:51

DBX4 随 Delphi 2007/2009 一起推出。 您可以使用那里的低级结构以编程方式创建数据库。 查看dbxcommons.pas

With Delphi 2007/2009 comes DBX4. You may use the low level structures there to create database programmatically. Look in dbxcommons.pas

非要怀念 2024-07-17 18:37:51

您可以通过任何服务器(甚至 ms-access 文件)上打开的任何连接(ADO、OLEDB、ODBC 等)发送“CREATE DATABASE”脚本,只要它遵循特定的服务器 DDL 语法即可。

You can send a "CREATE DATABASE" script through any connection (ADO, OLEDB, ODBC, etc) opened on any server (or even ms-access files) as long as it follows the specific server DDL syntax.

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