List all sequences in a Postgres db 8.1 with SQL

后端 未结 19 1707
旧时难觅i
旧时难觅i 2020-12-12 11:30

I\'m converting a db from postgres to mysql.

Since i cannot find a tool that does the trick itself, i\'m going to convert all postgres sequences to autoincrement id

19条回答
  •  离开以前
    2020-12-12 11:46

    Kind of a hack, but try this:

    select 'select ''' || relname || ''' as sequence, last_value from ' || relname || ' union' FROM pg_catalog.pg_class c WHERE c.relkind IN ('S','');

    Remove the last UNION and execute the result

提交回复
热议问题