在 windows 中连接 postgres 的批处理文件

Batch file to connect postgres in windows

您好专家我是 postgres 的新手,我必须从批处理文件中单击一次从表 1 中删除数据。我不知道如何从 windows.It 中的批处理文件连接 postgres 中的数据库,如果你能给我提供整个脚本示例,那对我来说会更好。我的dbname-"test", dbuser-"postgres", password="pes".

您可以像这样批量传输命令。

(
echo DELETE FROM table_name where something=somethig;
) | D:/pgsql/bin/psql -h somehost -p 5432 -U postgres -d test 

不过,我建议您先尝试做一个 select from 作为测试,然后再启动任何 deletes 以确保您不会删除您不想删除的内容

(
echo SELECT * FROM tablename;
) | D:/pgsql/bin/psql -h somehost -p 5432 -U postgres -d test