| От | Scott Marlowe |
|---|---|
| Тема | Re: Establishing a primary key |
| Дата | |
| Msg-id | 467C3334.7080108@g2switchworks.com обсуждение исходный текст |
| Ответ на | Establishing a primary key (Bob Pawley <rjpawley@shaw.ca>) |
| Список | pgsql-general |
Bob Pawley wrote: > I have numerous entries in a column of table 1, some of which are > duplicated. > > I need to transfer this information to table 2 so that I have column > that can be used as a primery key. > > Any help is appreciated. So, I take it you're wanting to have this so that table 1 stays as it is, and table 2 gets the entries from table 1 made unique, and becomes the parent of table 1? If that's the case, you want something like this: create table2 as select distinct idcolumn from table1; alter table2 add primary key (idcolumn); alter table1 add foreign key (idcolumn) references table2(idcolumn); I think that's about right.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера