Skip site navigation (1) Skip section navigation (2)

Re: Creating a table

From: Basil Bourque <basil(dot)list(at)me(dot)com>
To: seapug(at)postgresql(dot)org
Subject: Re: Creating a table
Date: 2010-09-27 02:22:27
Message-ID: A3DF32E0-F6D9-4CF2-B8CC-53F1AD137FF2@me.com (view raw or flat)
Thread:
Lists: seapug
On Sep 16, 2010, at 15:38, Albin, Lloyd P wrote:

> For learning you can create
> all your queries in public

Thank you for the clear answer.

I have another question: What is the best way in pgAdmin3 (Postgres 9) to define a primary key column?

I learned how to add a constraint defining the primary key. But that does not seem to cause a sequence number to be generated when I use pgAdmin's Edit Data feature to create a row.

I read about the "serial" & "bigserial" pseudo-data type to define an auto-incrementing integer.
http://www.postgresql.org/docs/9/interactive/datatype-numeric.html

That page suggests 2 steps:

(1) Define the datatype of the column to "serial" (or 'bigserial') 
A "NOT NULL" constraint is automatically added.

(2) Add a constraint of PRIMARY KEY.

Is that the best practice? Normally I'd prefer writing more standard SQL than "SERIAL", but that single word is so much shorter than the alternative. 

What happens when you use pgDump to re-create a database? Do I manually reset the sequences?

I'd much rather use UUIDs as my primary key, but my app development toolkit & database driver does not support UUIDs.

--Basil Bourque

In response to

Responses

seapug by date

Next:From: Albin, Lloyd PDate: 2010-09-27 15:21:30
Subject: Re: Creating a table
Previous:From: Albin, Lloyd PDate: 2010-09-16 22:38:07
Subject: Re: Creating a table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group