[DUG] Change a VarChar(255) into a VarChar(20) - Firebird

Karl at Work karlreynolds at xtra.co.nz
Mon May 8 14:19:17 NZST 2006


> I have an Firebird database with a field that stores a small string 
> value in a VarChar(255). I want to change that now to a VarChar(20) 
> which is plenty big enough so that I can create an index on 
> it. But of 
> course, Firebird won't let me reduce the varchar size since it is 
> already populated (although no values over 20 chars long).

alter table <tablename> add tempcolumn varchar(20);
update <tablename> set tempcolumn = <sourcecolumn>;
alter table <tablename> drop <sourcecolumn>;
alter table <tablename> alter tempcolumn to <sourcecolumn>;

Cheers,
Carl


More information about the Delphi mailing list