[GENERAL] Getting the currently used sequence for a SERIAL column

2016-09-29 Thread Hanne Moa
Hi, we have up until now, been using pg_get_serial_sequence() to discover which sequence is in use, but can no longer do so due to two tables needing to share the same sequence (prior to being properly merged. No duplicate values, luckily). For one of the tables, pg_get_serial_sequence() won't be

Re: [GENERAL] Getting the currently used sequence for a SERIAL column

2016-10-19 Thread Hanne Moa
On 2016-10-19 09:28, Thomas Kellerer wrote: > You can use the following statement to find the sequences that a table uses: > > select sn.nspname as sequence_schema, s.relname as sequence_name > from pg_class s > join pg_namespace sn on sn.oid = s.relnamespace > join pg_depend

Re: [GENERAL] Getting the currently used sequence for a SERIAL column

2016-10-19 Thread Hanne Moa
On 2016-10-18 16:11, Tom Lane wrote: > regression=# create table t1 (f1 serial); > CREATE TABLE > regression=# select * from pg_depend where objid = 't1_f1_seq'::regclass or > refobjid = 't1_f1_seq'::regclass; > classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype >

[GENERAL] Getting the currently used sequence for a SERIAL column

2016-10-18 Thread Hanne Moa
Hi, Until now we've been using pg_get_serial_sequence() to discover which sequence is in use, but can no longer do so due to two tables needing to share the same sequence (prior to being properly merged. No duplicate values, luckily). For one of the tables, pg_get_serial_sequence() won't be