pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: yanliang lei <msdnchina@163.com>
To: pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>
Subject: Supplements and suggestions and about postgresql sequence setval function in the documents
Date: Wed, 21 Aug 2024 20:23:40 +0800 (CST)
Message-ID: <33f1f47d.9f8f.19174e48943.Coremail.msdnchina@163.com> (raw )
in the following example;
select setval('seq_test',111);
---this setval('seq_test',111) : update the current schema's seq_test last_value =111
select setval('schemalei.seq_test',222);
---this setval('seq_test',111) : update the schemalei schema's seq_test last_value =222
but in the setval document(https://www.postgresql.org/docs/current/functions-sequence.html ), there is no description about it.
[pg164@localhost bin]$ ./psql -d postgres
psql (16.4)
Type "help" for help.
postgres=# \d
Did not find any relations.
postgres=#
postgres=#
postgres=# create schema schemalei;
CREATE SCHEMA
postgres=# create sequence public.seq_test ;
CREATE SEQUENCE
postgres=# create sequence schemalei.seq_test ;
CREATE SEQUENCE
postgres=# show search_path;
search_path
-----------------
"$user", public
(1 row)
postgres=# \dus
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
pg164 | Superuser, Create role, Create DB, Replication, Bypass RLS
postgres=# select * from pg_sequences;
schemaname | sequencename | sequenceowner | data_type | start_value | min_value | max_value | increment_by | cycle | cache_size | last_value
------------+--------------+---------------+-----------+-------------+-----------+---------------------+--------------+-------+------------+------------
public | seq_test | pg164 | bigint | 1 | 1 | 9223372036854775807 | 1 | f | 1 |
schemalei | seq_test | pg164 | bigint | 1 | 1 | 9223372036854775807 | 1 | f | 1 |
(2 rows)
postgres=# select setval('seq_test',111);
setval
--------
111
(1 row)
postgres=# select setval('schemalei.seq_test',222);
setval
--------
222
(1 row)
postgres=# select * from pg_sequences;
schemaname | sequencename | sequenceowner | data_type | start_value | min_value | max_value | increment_by | cycle | cache_size | last_value
------------+--------------+---------------+-----------+-------------+-----------+---------------------+--------------+-------+------------+------------
public | seq_test | pg164 | bigint | 1 | 1 | 9223372036854775807 | 1 | f | 1 | 111
schemalei | seq_test | pg164 | bigint | 1 | 1 | 9223372036854775807 | 1 | f | 1 | 222
(2 rows)
postgres=# select version();
version
-----------------------------------------------------------------------------
PostgreSQL 16.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.0, 64-bit
(1 row)
postgres=#
view thread (5+ messages) latest in thread
Message-ID: <33f1f47d.9f8f.19174e48943.Coremail.msdnchina@163.com>
Permalink: ../33f1f47d.9f8f.19174e48943.Coremail.msdnchina@163.com/
Also on: postgresql.org/message-id/33f1f47d.9f8f.19174e48943.Coremail.msdnchina@163.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: msdnchina@163.com, pgsql-docs@lists.postgresql.org
Subject: Re: Supplements and suggestions and about postgresql sequence setval function in the documents
In-Reply-To: <33f1f47d.9f8f.19174e48943.Coremail.msdnchina@163.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox