| From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Getting the currently used sequence for a SERIAL column |
| Date: | 2016-10-18 21:01:33 |
| Message-ID: | nu62ja$2uv$1@blaine.gmane.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashish Chauhan | 2016-10-18 22:15:47 | Postgres upgrade from 9.4.9 to 9.6 using pg_upgrade error |
| Previous Message | Simon Riggs | 2016-10-18 20:41:00 | Re: tablesample performance |