On 3/31/21 10:51 AM, Ian Lawrence Barwick wrote:
> 2021年3月31日(水) 17:35 Sebastien FLAESCH <sf@4js.com>:
>>
>> Hello,
>>
>> How do I get the sequence name for a serial/bigserial column, of a table
>> and/or column name is created with uppercase letters?
>>
>> test1=> create table "TAB13" ( "PKEY" BIGSERIAL, "NAME" VARCHAR(50) );
>> CREATE TABLE
>>
>> test1=> select pg_get_serial_sequence(current_schema||'.tab13','pkey');
>> ERROR: relation "public.tab13" does not exist
>>
>> test1=> select pg_get_serial_sequence(current_schema||'.TAB13','PKEY');
>> ERROR: relation "public.tab13" does not exist
>
> Somewhat counterintuitively:
>
> postgres=# SELECT pg_get_serial_sequence('"TAB13"','PKEY');
> pg_get_serial_sequence
> -------------------------
> public."TAB13_PKEY_seq"
> (1 row)
>
> Regards
>
> Ian Barwick
>
> --
> EnterpriseDB: https://www.enterprisedb.com
>
>
Ok thanks a lot I got it now, must specify double-quotes around table name.
test1=> select pg_get_serial_sequence(current_schema||'."TAB13"','PKEY');
pg_get_serial_sequence
-------------------------
public."TAB13_PKEY_seq"
Seb