Created
December 18, 2013 16:06
-
-
Save unarist/8024930 to your computer and use it in GitHub Desktop.
PostgreSQLでシーケンスを今の最大値にリセットする ref: http://qiita.com/unarist@github/items/1ef370933d5745d9c336
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
'select setval(''' || sequence || ''', (select max(' || column_name || ') from ' || table_name || '));' as setval | |
from | |
( | |
select | |
table_name | |
, column_name | |
, substr(column_default, 10, length(column_default) - 21) as sequence | |
from | |
information_schema.columns | |
where | |
table_schema = 'public' | |
and column_default like 'nextval(%' | |
) a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment