Re: A couple of newbie questions ...

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: A couple of newbie questions ...
Дата
Msg-id D960CB61B694CF459DCFB4B0128514C20256FE98@exadv11.host.magwien.gv.at
обсуждение исходный текст
Ответ на A couple of newbie questions ...  (admin <mick@mjhall.org>)
Список pgsql-general
admin wrote:
> So anyway, life story aside, I have a couple of very newbie questions
> after tinkering with PostgreSQL 8.1.9 for a day converting some
> PHP/MySQL code:

Here I have to ask the obvious thing: Why not a more current version?

> 1. Is a SEQUENCE what I use instead of auto_increment?

Yes. Even better, you can use the pseudo-type "serial" and "bigserial"
which is in reality "integer" and "bigint" with nextval(...) in DEFAULT.
The advantage over an explicitly created sequence is that with "serial",
the sequence will be dropped automatically if the table is dropped.

Consult the documentation for details!

> 2. Does this work in PostgreSQL:
>
> INSERT INTO table VALUES ('x','y','z')
>
> or do I need to do this
>
> INSERT INTO table (fld_x,fld_y,fld_z) VALUES ('x','y','z')

The first will work as specified by the SQL standard.

> 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?
> If not, what is an alternative?

No, this won't work.

Use:

INSERT INTO table (fld_y, fld_z) VALUES ('y','z')

Yours,
Laurenz Albe

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

Предыдущее
От: "Guillaume Bog"
Дата:
Сообщение: Re: High activity short table and locks
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: A couple of newbie questions ...