2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PostgreSQLのシーケンス確認と設定

Last updated at Posted at 2023-06-01

1.シーケンスの一覧を取得

SELECT * FROM pg_sequences;
→シーケンス名(sequencename)が取得できる

2.シーケンスの現在値確認

select last_value from '対象のシーケンス名' ;
例:select last_value from test_record_id_seq ;

3.シーケンス1つ進める

select nextval ('対象のシーケンス名');
例:select nextval ('test_record_id_seq');

4.シーケンスの値を設定

select setval ('対象のシーケンス名',設定値);
例:select setval('test_record_id_seq', 160);

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?