Re: Alter definition of a column

Поиск
Список
Период
Сортировка
От Kelly Burkhart
Тема Re: Alter definition of a column
Дата
Msg-id fa1e4ce70701200919h2217e1e2pc140deb21b9c81@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Alter definition of a column  ("Shoaib Mir" <shoaibmir@gmail.com>)
Ответы Re: Alter definition of a column  ("Shoaib Mir" <shoaibmir@gmail.com>)
Re: Alter definition of a column  ("Josh Williams" <drykath@runbox.com>)
Re: Alter definition of a column  ("Jim C. Nasby" <jim@nasby.net>)
Список pgsql-general
On 1/20/07, Shoaib Mir <shoaibmir@gmail.com> wrote:
> Should help --> ALTER TABLE tablename ALTER columname TYPE text;

I was looking for a way to alter a column from varchar(n) to text
without using the alter command and consequently touching every single
row.  Below is sql which seems to work, but is it advisable to do such
shenanigans?  (are varchar and text the same thing)?

kelly=# create table foo( c1 varchar(4) not null, c2 text not null );
CREATE TABLE
kelly=#
kelly=# update pg_attribute set atttypid=25, atttypmod=-1
kelly-# where attname = 'c1' and attrelid =
kelly-#     (select oid from pg_class where relname = 'foo');
UPDATE 1
kelly=#
kelly=# \d foo
    Table "public.foo"
 Column | Type | Modifiers
--------+------+-----------
 c1     | text | not null
 c2     | text | not null

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Help : Microsoft SQL Server equivalents in
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: Help : Microsoft SQL Server equivalents in