Re: Auto-increment Numeric Primary keys - Mailing list pgsql-general

From Mike Mascari
Subject Re: Auto-increment Numeric Primary keys
Date
Msg-id 394D4875.83D61D33@mascari.com
Whole thread Raw
In response to Auto-increment Numeric Primary keys  ("Vipin Samtani" <vipin@attglobal.net>)
List 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

pgsql-general by date:

Previous
From: "Vipin Samtani"
Date:
Subject: Auto-increment Numeric Primary keys
Next
From: "Brett W. McCoy"
Date:
Subject: Re: Auto-increment Numeric Primary keys