Adding columns to existing tables
От | John Pagakis |
---|---|
Тема | Adding columns to existing tables |
Дата | |
Msg-id | A04BDD2C264AD41181C000508BDCB72A71A0A4@usazdolexch0.developonline.home обсуждение исходный текст |
Ответы |
Re: Adding columns to existing tables
|
Список | pgsql-admin |
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? I have resorted to creating a company_temp table, insert into company_temp selecting from company, dropping company and then renaming company_temp to company. This works, but causes another problem. The index for the unique key company_temp_pkey does not get renamed with the table. This means if I ever want to do something like this again, the create of company_temp will fail because company_temp_pkey already exists. Any help would be much appreciated. _______________________________________ John Pagakis DevelopOnline.com 480.377.6828 <<John Pagakis.vcf>>
Вложения
В списке pgsql-admin по дате отправления: