获取数据库的参数?

wlq 2000-03-14 06:36:00
一个数据库表,根据其字段类型等参数建一个一样的空表。。。
也就是获取以下一些数据库参数:
表的字段名,类型,索引,触发器内容等等,就是我们用sql explorer看到的那样
请问如何编程获得?如果用bde具体该怎么做,bde的api函数我一个都不会:(
...全文
236 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlq 2000-03-17
  • 打赏
  • 举报
回复
多谢指教
渤海海峡 2000-03-16
  • 打赏
  • 举报
回复
为什么不看看interbase的help?
下面是我摘的:
ALTER TABLE enables the structure of an existing table to be modified. A single ALTER TABLE can perform multiple adds and drops.
Naming column constraints is optional. If a name is not specified, InterBase assigns a system-generated name. Assigning a descriptive name can make a constraint easier to find for changing or dropping, and easier to find when its name appears in a constraint violation error message.
A table can be altered by its creator and the SYSDBA user.
ALTER TABLE fails if current data in a table violates a PRIMARY KEY or UNIQUE constraint definition added to the table. It also fails if a column to be dropped is:

Part of a UNIQUE, PRIMARY, or FOREIGN KEY constraint, or is used in a CHECK constraint.
Used in the value expression of a computed column.

Drop the constraint or computed column before dropping the table column. PRIMARY KEY and UNIQUE constraints cannot be dropped if referenced by FOREIGN KEY constraints. In these cases, drop the FOREIGN KEY constraint before dropping the PRIMARY KEY or UNIQUE key it references.
When altering a column based on a domain, an additional CHECK constraint can be supplied for the column. Changes to tables that contain CHECK constraints with subqueries may cause constraint violations.

临时表应该放到客户端!
服务器只要安装interbase就可以了,客户端要安装 interbase client & BDE.
Lin 2000-03-16
  • 打赏
  • 举报
回复
To wlq:
  昨天没上网。
  除非在创建Table的时候创建索引,否则不会自动创建。当然也可以没有索引,但试图访问索引的时候就会出发异常,‘报错说我要设的索引不存在’...
  我的戴妃5并没有你所说的‘delphi 5/DEMOS/Data ’目录。临时表放在哪里无所谓,其实我们什么时候关心过其物理存放位置?由于你使用了数据库,在发布你的应用程序时还的附带上BDE驱动,倒也用不着完全安装戴妃5,你说是吧?
  至于‘delphi报错:'(a)'是valid use of keyword’,如果你有MSDN的光盘(肯定有,程序员的必备之物)的话,可以用关键字‘ALTER ’去查找关于 ALTER TABLE语法的完整说明。
wlq 2000-03-15
  • 打赏
  • 举报
回复
谢谢Lin,看来我得抓紧学习了
我又遇到了问题,我在程序中建了个临时表,现在要加上索引:
alter table test
add constraint index_1
primary key(a)
delphi报错:'(a)'是valid use of keyword
请问如何解决?
Lin 2000-03-15
  • 打赏
  • 举报
回复
设置Table的IndexName或者IndexFieldNames属性不更好吗?
wlq 2000-03-15
  • 打赏
  • 举报
回复
忘了说明,我用的是TQuery,不是TTable
我刚才试了一下,在TTable中设索引不行,indexdefs,indexname,indexfiednames
都不行,报错说我要设的索引不存在,indexdefs 是只读属性。
sql only?
怎么办?
wlq 2000-03-15
  • 打赏
  • 举报
回复
我还是想知道这个sql语句为什么出错:)
因为在interbase中要修改表就得输sql语句。
用sql不光可以设索引,还可以设主关键字,外部关键字等
Lin,我做了个临时表,我发现它位于DBDEMOS下,目录为
...delphi 5/DEMOS/Data 中,这是否意味着我在发布时
要在服务器端完整安装D5?
Lin 2000-03-14
  • 打赏
  • 举报
回复
1、字段名TTable的Fields应该获取表的所有字段,为一数组,再利用TField的FieldKind、FieldName、FieldNo等就可以获取表的字段名,类型..
2、索引信息可以由TTable的IndexDefs、IndexFieldCount、IndexFieldNames、IndexFields、IndexFiles、IndexName等属性获得。

2,496

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧