From: | Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: A couple of newbie questions ... |
Date: | 2008-07-23 10:16:46 |
Message-ID: | 20080723101646.GA3883@merkur.hilbert.loc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jul 23, 2008 at 07:18:15PM +0930, admin wrote:
> 1. Is a SEQUENCE what I use instead of auto_increment?
Yes. Perhaps better use it indirectly with (BIG)SERIAL:
create table foo (
pk (big)serial
);
> 2. Does this work in PostgreSQL:
>
> INSERT INTO table VALUES ('x','y','z')
Yes, as long as the values are intended for the first N
consecutive columns.
> or do I need to do this
>
> INSERT INTO table (fld_x,fld_y,fld_z) VALUES ('x','y','z')
You don't have to but while it is a bit more typing it is
more future proof.
> 3. Does this work in PostgreSQL:
>
> INSERT INTO table VALUES ('','y','z')
>
> where the empty first item is intended for an auto_increment/SEQUENCE id
> field?
No.
> If not, what is an alternative?
insert into table (auto_inc_col, a, b) values (DEFAULT, 'y', 'z');
insert into table (a, b) values ('y', 'z');
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2008-07-23 10:16:56 | Re: A couple of newbie questions ... |
Previous Message | Craig Ringer | 2008-07-23 10:10:28 | Re: A couple of newbie questions ... |