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

Re: [GENERAL] primary key attribute

From: Billy Donahue <donahu(at)cooper(dot)edu>
To: Joao Paulo Felix <felix(at)cyclades(dot)com>
Cc: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>
Subject: Re: [GENERAL] primary key attribute
Date: 1998-05-29 21:37:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Joao Paulo Felix wrote:
> Hi there,
> I am having trouble trying to alter a class and update an column
> constraint to PRIMARY KEY. I decided to create a new table using the
> following, still it does seem work:
> CREATE TABLE my_table
>         (my_column INT PRIMARY KEY, my_column2 TEXT);
> Could any one help me please. Thanks in advance.
> Joao Paulo

I'm new to this myself, but I know there's no 
PRIMARY KEY in the SQL subset supported by PostgreSQL.

You can get the same effect by
CREATE TABLE my_table (my_column INT, my_column2 TEXT);

CREATE UNIQUE INDEX my_table_my_column_key 
	ON my_table(my_column);

Then you'll be guaranteed that all records will have 
distinct my_column integers.  Hope this helps.

In response to

pgsql-general by date

Next:From: Oliver ElphickDate: 1998-05-29 22:15:28
Subject: Re: [GENERAL] primary key attribute
Previous:From: Kurt SeelDate: 1998-05-29 19:07:33
Subject: problem: using large objects from tcl

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