Re: Auto-increment Numeric Primary keys

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Vipin Samtani <Vipin(dot)Samtani(at)cornell(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Auto-increment Numeric Primary keys
Date: 2000-06-18 22:08:53
Message-ID: 394D4875.83D61D33@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vipin Samtani wrote:
>
> How can I auto-increment numeric primary keys? So on a table called
> "Test1" with fields "ID" and "Name" when I do an INSERT, I only type
>
> INSERT INTO Test1 values ('Bob');
>
> instead of
>
> INSERT INTO Test1 values (1, 'Bob');
>
> Is this implemented in PostgreSQL 7?
>
> -Vipin

CREATE TABLE Test1 (
id SERIAL,
name TEXT
);

INSERT INTO Test1(name) VALUES ('Bob');

SELECT * FROM Test1;

id|name
--+----
1|Bob
(1 row)

Hope that helps,

Mike Mascari

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brett W. McCoy 2000-06-18 22:20:52 Re: Auto-increment Numeric Primary keys
Previous Message Vipin Samtani 2000-06-18 21:51:33 Auto-increment Numeric Primary keys