Re: Getting the currently used sequence for a SERIAL column

Поиск
Список
Период
Сортировка
От Hanne Moa
Тема Re: Getting the currently used sequence for a SERIAL column
Дата
Msg-id c9fb31f1-4cf4-607f-f336-e0a15ea83222@gmail.com
обсуждение исходный текст
Ответ на Re: Getting the currently used sequence for a SERIAL column  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Getting the currently used sequence for a SERIAL column  (Thomas Kellerer <spam_eater@gmx.net>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: pg_sample
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Getting the currently used sequence for a SERIAL column