Search code examples
postgresqlpsqlidentity

psql generated by default identity and sequences names


my question is simple what is the current value for the identity and how to retrieve it's sequence name

CREATE TABlE x(
          id int2 generated by default as identity
          (start 5) 
           primary key,
           name varchar(5))

Solution

  • From here Info functions:

    select pg_get_serial_sequence ('x', 'id' );
    
     pg_get_serial_sequence     
    --------------------------------
     <some_seq_name>
    
    
    --Then
    
    Select * from <some_seq_name>;