Re: A couple of newbie questions ...

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: A couple of newbie questions ...
Дата
Msg-id 20080723101646.GA3883@merkur.hilbert.loc
обсуждение исходный текст
Ответ на A couple of newbie questions ...  (admin <mick@mjhall.org>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: A couple of newbie questions ...
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: A couple of newbie questions ...