Re: [INTERFACES] How do I drop a column from a table?

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: [INTERFACES] How do I drop a column from a table?
Дата
Msg-id 37CBE501.6BC68052@alumni.caltech.edu
обсуждение исходный текст
Ответ на Re: [INTERFACES] How do I drop a column from a table?  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Список pgsql-interfaces
> > Adding columns is directly supported. Removing columns, or redefining
> > them, is done with a CREATE TABLE AS/DROP TABLE/CREATE TABLE AS/DROP
> > TABLE sequence, where you write the columns you want to retain into a
> > temporary table, delete the original table, and then do the same back
> > into a new table with the same name as the original.
> But this method might lose some characteristics such as primary key,
> unique constraints, no?

OK, then CREATE TABLE AS/DROP TABLE/CREATE TABLE/INSERT/DROP TABLE,
where the CREATE TABLE can include all relevant characteristics.

btw, Tatsuo reminds me that if you have a SERIAL type, you will need
to retain the underlying sequence which supports it, define the column
in the new table as an INT, and define the DEFAULT clause for it to
reference the sequence explicitly.
                       - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


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

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: [INTERFACES] How do I drop a column from a table?
Следующее
От: Rusty Brooks
Дата:
Сообщение: Re: [INTERFACES] ODBC Questions