Re: Getting the currently used sequence for a SERIAL column

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Getting the currently used sequence for a SERIAL column
Дата
Msg-id nu62ja$2uv$1@blaine.gmane.org
обсуждение исходный текст
Ответ на Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom Lane schrieb am 18.10.2016 um 16:11:
>> I thought pg_depend only stores the dependency if the the sequence was assigned
>> an owning column (through OWNED BY).
>
> No, there will be regular expression dependencies as well.
>
> That 'a' dependency is the one that pg_get_serial_sequence() looks for,
> but the default-to-sequence dependency will be there in any case.
>
> regression=# create table t2(f2 int default nextval('t1_f1_seq'));
> CREATE TABLE
> regression=# select pg_describe_object(classid,objid,objsubid) as
> obj, pg_describe_object(refclassid,refobjid,refobjsubid) as ref,
> deptype from pg_depend where objid = 't1_f1_seq'::regclass or
> refobjid = 't1_f1_seq'::regclass;
>               obj               |        ref         | deptype
> --------------------------------+--------------------+---------
>  type t1_f1_seq                 | sequence t1_f1_seq | i
>  sequence t1_f1_seq             | schema public      | n
>  default for table t1 column f1 | sequence t1_f1_seq | n
>  sequence t1_f1_seq             | table t1 column f1 | a
>  default for table t2 column f2 | sequence t1_f1_seq | n

Great, thanks. I meant to include that dependency in my SQL Workbench as well,
but could never find the correct way of joining the tables.





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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: tablesample performance
Следующее
От: Patrick B
Дата:
Сообщение: pg_sample