Re: Re: nextval, sequences and sequencenames

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Re: nextval, sequences and sequencenames
Дата
Msg-id 20010815180443.A9969@svana.org
обсуждение исходный текст
Ответ на Re: nextval, sequences and sequencenames  (Chris <csmith@squiz.net>)
Список pgsql-general
On Wed, Aug 15, 2001 at 12:14:02PM +1000, Chris wrote:
> >If it is very difficult finding that sequence name (I'm not sure)
> >You may want to create the sequence yourself instead of using SERIAL.
> >Then you would know the name.
>
> Not hard at all.
>
> csmith=# create table test (testid serial, name text);
> NOTICE:  CREATE TABLE will create implicit sequence 'test_testid_seq' for
> SERIAL column 'test.testid'
> NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_testid_key'
> for table 'test'
> CREATE
>
> Sequence name becomes <tablename>_<columnname>_seq

Actually, it's a bit more complicated than that. Since the maximum
identifier length is 32 or so, if the above identifier comes out too long,
various rules are applied to make it shorter.

If you want a guarenteed name, I suggest not using serial and building the
sequence yourself. Then you can use any naming convention you like.

--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> It would be nice if someone came up with a certification system that
> actually separated those who can barely regurgitate what they crammed over
> the last few weeks from those who command secret ninja networking powers.

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

Предыдущее
От: "Alexander Fordyce"
Дата:
Сообщение: OpenBSD 2.9 - installation works fine but psql won't run
Следующее
От: Wieger Uffink
Дата:
Сообщение: Re: Re: nextval, sequences and sequencenames