Search Postgresql Archives

Re: Getting the currently used sequence for a SERIAL column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux