Re: Getting the currently used sequence for a SERIAL column - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Getting the currently used sequence for a SERIAL column
Date
Msg-id nu62ja$2uv$1@blaine.gmane.org
Whole thread Raw
In response to Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Simon Riggs
Date:
Subject: Re: tablesample performance
Next
From: Patrick B
Date:
Subject: pg_sample