Re: Multiple Primary Keys
От | Josh Berkus |
---|---|
Тема | Re: Multiple Primary Keys |
Дата | |
Msg-id | web-1375947@davinci.ethosmedia.com обсуждение исходный текст |
Ответ на | Multiple Primary Keys ("samsom, debra" <dsamsom@bristol.ca>) |
Ответы |
Altering psqlodbc.h
|
Список | pgsql-novice |
Debra, > Currently I have a table on Microsoft Sequel Server that I wish to > port over > to Postgresql. This table has four primary keys and it's the > combination > of the four fields that make the record unique. Just to get your terminology straight: What you have is a *single* primary key, consisting of four fields. You cannot have more than one primary key for a table. I would strongly suggest that you re-consider your database design: composite primary keys (which is what you have) are a *lot* of trouble. A surrogate key (such as an auto-incrementing integer) would be much easier to handle. For more information, I strongly reccomend the book "Database Design for Mere Mortals." > "Cannot insert a duplicate key into unique index attachments_pkey" Yes. You have duplicate data somewhere in the table. The primary key must be unique. Try this: SELECT "docn","issue","docna","issuea", count(*) FROM attachments GROUP BY "docn","issue","docna","issuea" HAVING count(*) > 1; This should list all of your duplicates. If you get a "NULL Value Eliminated From Aggregate" warning, that means that one or more of those columns has a NULL value, which must either be filled in, or you must exclude it fromm the Primary Key. -Josh Berkus
В списке pgsql-novice по дате отправления: