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.