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.