Postgresql 数据库维护

删除数据库

sudo -u postgres dropdb $DB_NAME

创建数据库

sudo -u postgres psql
CREATE DATABASE $DB_NAME WITH ENCODING='UTF8' OWNER=$DB_OWNER;

导出数据库

pg_dump -h $DB_HOST -U $DB_USER --clean --schema=$DB_SCHEMA -d $DB_NAME > $DUMP_FILE_NAME

导入数据库

psql -U $DB_USER -d $DB_NAME < $DUMP_FILE_NAME

扩大Sequence
SELECT c.relname FROM pg_class c WHERE c.relkind = 'S' order by c.relname;

SELECT SETVAL('seq_name', NEXTVAL('seq_name')+10000);

删除SCHEMA

DROP SCHEMA $schema CASCADE

你可能感兴趣的:(PostgreSQL)