//-更改字段名称将字段aa修改成c_aa with adocommand1 do begin CommandText:='ALTER TABLE 表1 ADD COLUMN c_aa text(150)'; Execute; CommandText:='update 表1 set c_aa=aa'; Execute; CommandText:='ALTER TABLE 表1 DROP COLUMN aa'; Execute; end; //-修改字段类型 with adocommand1 do begin CommandText:='ALTER TABLE 表1 alter COLUMN c_aa text(100)'; Execute; end;
查了一下,看来只能用楼上的方法修改字段名,不能直接修改啊 修改数据类型可以:ALTER TABLE Employees ALTER COLUMN ZipCode TEXT(10)
with adocommand1 do
begin
CommandText:='ALTER TABLE 表1 ADD COLUMN c_aa text(150)';
Execute;
CommandText:='update 表1 set c_aa=aa';
Execute;
CommandText:='ALTER TABLE 表1 DROP COLUMN aa';
Execute;
end;
//-修改字段类型
with adocommand1 do
begin
CommandText:='ALTER TABLE 表1 alter COLUMN c_aa text(100)';
Execute;
end;
修改数据类型可以:ALTER TABLE Employees ALTER COLUMN ZipCode TEXT(10)
有意思,你干脆跑到access表设计器里去直接修改得了