# postgresql数据库表的迁移 **Repository Path**: f77yue/migration-of-postgres-database-table ## Basic Information - **Project Name**: postgresql数据库表的迁移 - **Description**: postgresql数据库表的迁移和拷贝表结构创建新表 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-17 - **Last Updated**: 2022-02-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # postgresql数据库表的迁移 #### 介绍 postgresql数据库表的迁移和拷贝表结构创建新表 #### 表和数据的导出 pg_dump -O -h localhost -p 5432 -U loreal -d dialogue_dev -t live.comments > g.sql #### 表结构的导出 pg_dump -s -h localhost -p 5432 -U loreal -d dialogue_dev -t live.comments > g.sql #### 数据库导出 pg_dump -U TestRole1 -O -f TestDb1.sql TestDb1 #### 数据表导入 psql -h localhost -d dialogue_dev -U loreal -f g.sql #### 数据库表迁移之后更新最大id SELECT setval('{seq_name}', COALESCE((SELECT MAX(id)+1 FROM {table_name}), 1), false);