From: | Hanne Moa <hanne(dot)moa(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Getting the currently used sequence for a SERIAL column |
Date: | 2016-10-19 07:06:49 |
Message-ID: | c9fb31f1-4cf4-607f-f336-e0a15ea83222@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
> ---------+-------+----------+------------+----------+-------------+---------
> 1247 | 47198 | 0 | 1259 | 47197 | 0 | i
> 1259 | 47197 | 0 | 2615 | 2200 | 0 | n
> 2604 | 47202 | 0 | 1259 | 47197 | 0 | n
> 1259 | 47197 | 0 | 1259 | 47199 | 1 | a
> (4 rows)
This seems to assume that I already know the name of the sequence?
Looking at the sequence names that's already in use, I cannot safely
assume anything about the format of their names. I start out knowing
only the table and column, and I need a string with the sequence name to
pass on to whatever wants it.
As for pg_describe_object,
SELECT pg_describe_object(classid,objid,objsubid) AS obj FROM pg_depend
WHERE obj LIKE 'default%';
leads to "ERROR: column "obj" does not exist" on 9.5.
Is the problem of restoring a database with sequences altered still a
problem in 9.3+?
https://www.postgresql.org/message-id/44D33E94.3010100%40list.za.net
HM
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2016-10-19 07:28:55 | Re: Getting the currently used sequence for a SERIAL column |
Previous Message | Adrian Klaver | 2016-10-19 04:05:20 | Re: pg_sample |