List all sequences in a Postgres db 8.1 with SQL

后端 未结 19 1773
旧时难觅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:47

    after a little bit of pain, i got it.

    the best way to achieve this is to list all tables

    select * from pg_tables where schemaname = ''
    

    and then, for each table, list all columns with attributes

    select * from information_schema.columns where table_name = ''
    

    then, for each column, test if it has a sequence

    select pg_get_serial_sequence('', '')
    

    and then, get the information about this sequence

    select * from 
    

提交回复
热议问题