关于table.field.add的用法(50分)

  • 主题发起人 主题发起人 gyq918
  • 开始时间 开始时间
G

gyq918

Unregistered / Unconfirmed
GUEST, unregistred user!
请问table.field.add在修改数据库结构时是怎么用的。是如何用来增加字段的
 
添加字段前,应将Table.Active := False关闭。
 
这东西能修改结构??顶多加个计算字段什么的。
 
修改结构必须用dbi!
 
1. 保存table.fielddefs
2. 关闭table
3. 复制原来的fielddefs
4. table.fielddefs.add或者addfielddef增加新字段定义
5. table.createtable
 
if not Table1.Exists then { Don't overwrite an existing table }

begin
with Table1 do
begin
Active := False; { The Table component must not be active }

{ First, describe the type of table and give it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';

{ Next, describe the fields in the table }
with FieldDefs do
begin
Clear;
Add('Field1', ftInteger, 0, True);
Add('Field2', ftString, 30, False);

end;

{ Next, describe any indexes }
with IndexDefs do
begin
Clear;
{ The first index has no name because it is a Paradox primary key }
Add('', 'Field1', [ixPrimary, ixUnique]);
Add('Fld2Indx', 'Field2', [ixCaseInsensitive]);
end;

{ Now that we have specified what we want, create the table }
CreateTable;
end;
end;
 
if not Table1.Exists then { Don't overwrite an existing table }

begin
with Table1 do
begin
Active := False; { The Table component must not be active }

{ First, describe the type of table and give it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';

{ Next, describe the fields in the table }
with FieldDefs do
begin
Clear;
Add('Field1', ftInteger, 0, True);
Add('Field2', ftString, 30, False);

end;

{ Next, describe any indexes }
with IndexDefs do
begin
Clear;
{ The first index has no name because it is a Paradox primary key }
Add('', 'Field1', [ixPrimary, ixUnique]);
Add('Fld2Indx', 'Field2', [ixCaseInsensitive]);
end;

{ Now that we have specified what we want, create the table }
CreateTable;
end;
end;
 
if not Table1.Exists then { Don't overwrite an existing table }

begin
with Table1 do
begin
Active := False; { The Table component must not be active }

{ First, describe the type of table and give it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';

{ Next, describe the fields in the table }
with FieldDefs do
begin
Clear;
Add('Field1', ftInteger, 0, True);
Add('Field2', ftString, 30, False);

end;

{ Next, describe any indexes }
with IndexDefs do
begin
Clear;
{ The first index has no name because it is a Paradox primary key }
Add('', 'Field1', [ixPrimary, ixUnique]);
Add('Fld2Indx', 'Field2', [ixCaseInsensitive]);
end;

{ Now that we have specified what we want, create the table }
CreateTable;
end;
end;

 
请问如何用dbi修改结构?
 
多人接受答案了。
 
后退
顶部