建表问题(20分)

  • 主题发起人 主题发起人 yunxi126
  • 开始时间 开始时间
Y

yunxi126

Unregistered / Unconfirmed
GUEST, unregistred user!
table1
one two three
--------- ---------- ----------------------
3 1985-10-27 1983-10-02 00:00:00.002
4 1984-02-01 1983-10-02 00:00:00.000
7 1986-01-01 1979-10-11 00:00:00.000
10 1987-10-10 1980-01-11 00:00:00.000

现在我要新建一个表.table2
表的列为table.one的值。字段的数据类型都是varchar值。
 
select one into table2 from table1
 
同意楼上,根据需要判断table2是否存在
 
不是。


现在我要新建一个表.table2
表的列(名)不是列值。为table.one的列值。字段的数据类型都是varchar值。
例如建成以后table2是这样的。
3(varchar) 4(varchar) 7(varchar) 10(varchar)
---------- ----------- ---------- ------------
 
table1
one two three
--------- ---------- ----------------------
3 1985-10-27 1983-10-02 00:00:00.002
4 1984-02-01 1983-10-02 00:00:00.000
7 1986-01-01 1979-10-11 00:00:00.000
10 1987-10-10 1980-01-11 00:00:00.000



table2
3 4 7 10
--------- ----------- -------------- --------
 
table2 也可是视图
 
最好是表
 
有没有高手来看看呀。
 
这个是老问题了吧,我懒得动哦
 
procedure TForm1.Button1Click(Sender: TObject);
begin
with table2 do
begin
Active:=false;
tablename:='testtable2';
if not fileexists('texttable2.db') then
begin
if not table1.Active then table1.Open;
table1.First;
while not table1.Eof do
begin
with table2.FieldDefs.AddFieldDef do
begin
Name :=table1.fieldbyname('one').AsString;
DataType := ftInteger;
end;
table1.Next;
end;
createtable;
active:=true;
table1.close;
end;
end;
end;
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
829
import
I
I
回复
0
查看
781
import
I
后退
顶部