Re: Adding Missing Data to a Table

From: Michael Ewan <michael(dot)ewan(at)intel(dot)com>
To: pdxpug(at)postgresql(dot)org
Subject: Re: Adding Missing Data to a Table
Date: 2011-03-29 20:43:32
Message-ID: 4D924474.7060702@intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pdxpug

On 03/29/2011 11:31 AM, Rich Shepard wrote:
> I'm now moving into areas of postgres I've not before visited so now and
> then I'll ask for directions.
>
> I have a table with 49365 rows. The first column, which I would like to
> use as an index, is called 'record' and of type VARCHAR(10). There are 39159
> rows in which record IS NULL. I would like to add values to 'record'
> starting with 30000. There's no significance to the value of this column
> other than as a unique row identifier, and the highest current value is
> 28569. What is the most efficient way to automate this?
>
>
Are you planning on using 'record' as a PK or simply an index? Will it
be an FK constraint on some other table. Is there a combination of
columns that would be unique so you could use them as a composite
primary key. It is generally a bad idea to use a synthetic key as a
primary key.
http://it.toolbox.com/blogs/database-soup/primary-keyvil-part-i-7327
If there is no significance to the record, then don't use it. The only
way you can safely update that column is using a unique primary key, and
if you create a unique primary key, you don't need the 'record' column
anymore.

In response to

Responses

Browse pdxpug by date

  From Date Subject
Next Message Rich Shepard 2011-03-29 20:53:46 Re: Adding Missing Data to a Table
Previous Message Dan Colish 2011-03-29 20:33:01 Re: Adding Missing Data to a Table