Re: your mail

From: Brian Baquiran <brianb(at)evoserve(dot)com>
To: <novikov(at)webclub(dot)ru>
Cc: pgsql-sql <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: your mail
Date: 1999-01-27 11:53:05
Message-ID: Pine.OSF.3.91.990127194710.1365A-100000@athena.evoserve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 27 Jan 1999, wrote:

> Hello.
>
> Before SERIAL type appeared I used INTEGER, so it was easy
> to add instance which is stored not in one table. Now when I
> have a primary key of SERIAL type I do not know how to add
> data to multiple tables (and even to one table too :)

If you have a column of SERIAL type, you have the option of not
specifying it in the column-list part of your INSERT statement.
PostgreSQL will add the next available integer to the serial type.

So if you create a table like so:

create table companies (
co_id serial,
co_name text);

You can INSERT like so:

insert into companies (co_name) values ('Microsoft');
insert into companies (co_name) values ('Netscape');

and assume that PostgreSQL will assign the lowest available integer
to your co_id field.

Note that you CAN specify a co_id when you do an insert, if you want to.

Brian

In response to

  • at 1999-01-27 10:52:35 from novikov

Browse pgsql-sql by date

  From Date Subject
Next Message Juan Pablo Marichal Catalan 1999-01-27 16:49:37 Please suscribe me.
Previous Message Herouth Maoz 1999-01-27 11:22:22 Re: