Re: convert char to varchar

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/18/07, Peter Koczan <pjkoczan@xxxxxxxxx> wrote:
> > Is there any other way to clear trailing spaces when I restore the table?
>
> If you're running 8.x, you can do this in place:
>
> ALTER TABLE c1 ALTER COLUMN name varchar(20) USING rtrim(name), ALTER
> COLUMN date varchar(20) USING rtrim(date);
>
> This could take a long time if the table is large or has a lot of indexes on it.

Oops. The command should be:

ALTER TABLE c1 ALTER COLUMN name TYPE varchar(20) USING rtrim(name),
ALTER COLUMN date TYPE varchar(20) USING rtrim(date);

I forgot the TYPE keyword...it's important.

Peter

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux