Her er en løsning:
@echo off
SET TableListeFile=C:\Users\mtuna\Documents\dumpfiles\database_list.txt
REM Saveing all tables name of database test_db on a temp file: database_list.txt
psql -U postgres -d test_db -t -c "SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE'" -o "%TableListeFile%"
REM Loop on liste tables name:
FOR /F "tokens=*" %%I IN (%TableListeFile%) DO (
REM Dump each table on file
pg_dump -U postgres -h localhost -t %%I test_db > "C:\Users\mtuna\Documents\dumpfiles\%%I.sql"
)
REM Delete temp file
del /Q %TableListeFile%
Det vil bede dig om adgangskodeinput for hver dump. Hvis du ikke ønsker at blive spurgt, kan du bruge Pgpass Fil .
Håber det hjælper.
Houari.