Re: Adding columns to existing tables
От | Stephan Szabo |
---|---|
Тема | Re: Adding columns to existing tables |
Дата | |
Msg-id | Pine.BSF.4.21.0105090858120.86660-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | Adding columns to existing tables (John Pagakis <John.Pagakis@DevelopOnline.com>) |
Список | pgsql-admin |
On Tue, 8 May 2001, John Pagakis wrote: > I have a table - suppose it is called company: > > CREATE TABLE ( company_id char(36) NOT NULL UNIQUE PRIMARY KEY, > . > . > . > ); > > I want to add the following field: > company_nemonic char( 3 ) NOT NULL UNIQUE > > Well, ALTER TABLE only gets me part of the way there. While this code > successfully adds the table: > ALTER TABLE > company > ADD COLUMN > company_nemonic char( 3 ) NOT NULL UNIQUE; > > the constraints are ignored. > > > Is there an easy way to add the constraints after the fact? Unique is easy, you can create a unique index on the column which is effectively what the unique constraint is doing behind the scenes. Not null is harder, IIRC, you need to go and actually toggle attnotnull in pg_attribute for the attribute.
В списке pgsql-admin по дате отправления: