0
0

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 5 years have passed since last update.

Postgresqlで現在のシーケンスの一覧を調べる

Posted at

うまいやり方を知りたい...

create or replace function func_dump_seq()
returns integer
AS '
DECLARE 
	rec RECORD;
	stmt VARCHAR(200);
	last_value INT;
BEGIN
	FOR rec IN SELECT sequence_name FROM information_schema.sequences ORDER BY sequence_name LOOP
		EXECUTE ''SELECT last_value FROM '' || rec.sequence_name || '';'' INTO last_value;
		RAISE NOTICE ''%->%'', rec.sequence_name, last_value;
	END LOOP;
	RETURN 0;
END;
'
language 'plpgsql';
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?