Windows系统中使用PostgreSQL命令批量清空数据库database
PSQL_Clear.bat
@echo off
set PGPASSWORD=123456798
set PGUSER=postgres
set PGDATABASE1=database1
set PGHOST=127.0.0.1
set PGPORT=5432
psql -U %PGUSER% -d %PGDATABASE1% -h %PGHOST% -p %PGPORT% -c "DROP SCHEMA public CASCADE;"
psql -U %PGUSER% -d %PGDATABASE1% -h %PGHOST% -p %PGPORT% -c "CREATE SCHEMA public;"
set PGDATABASE2=database2
psql -U %PGUSER% -d %PGDATABASE2% -h %PGHOST% -p %PGPORT% -c "DROP SCHEMA public CASCADE;"
psql -U %PGUSER% -d %PGDATABASE2% -h %PGHOST% -p %PGPORT% -c "CREATE SCHEMA public;"
pause
exit
网友评论