Postgresql 批处理文件以连接windows中的postgres

Postgresql 批处理文件以连接windows中的postgres,postgresql,batch-file,postgresql-9.4,Postgresql,Batch File,Postgresql 9.4,你好,专家,我是postgres的新手,我必须从批处理文件中单击一次从表1中删除数据。我不知道如何从windows中的批处理文件连接postgres中的数据库。如果您能提供完整的脚本和示例,对我来说会更好。我的dbname—“test”,dbuser—“postgres”,password=“pes”。您可以通过管道批处理命令,类似这样 ( echo DELETE FROM table_name where something=somethig; ) | D:/pgsql/bin/psql -h

你好,专家,我是postgres的新手,我必须从批处理文件中单击一次从表1中删除数据。我不知道如何从windows中的批处理文件连接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 
但是,我建议您在启动任何
删除操作之前,首先尝试从
中选择
作为测试,以确保您不会删除不想删除的内容

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