【发布时间】:2017-11-24 11:19:32
【问题描述】:
专家您好,我是 postgres 的新手,我必须通过单击批处理文件从 table1 中删除数据。我不知道如何从 windows 中的批处理文件连接 postgres 中的数据库。如果你能通过示例向我提供整个脚本,那对我来说会更好。我的 dbname-"test"、dbuser-"postgres"、password="pes"。
【问题讨论】:
标签: postgresql batch-file postgresql-9.4
专家您好,我是 postgres 的新手,我必须通过单击批处理文件从 table1 中删除数据。我不知道如何从 windows 中的批处理文件连接 postgres 中的数据库。如果你能通过示例向我提供整个脚本,那对我来说会更好。我的 dbname-"test"、dbuser-"postgres"、password="pes"。
【问题讨论】:
标签: postgresql batch-file postgresql-9.4
你可以只批量管道命令,像这样。
(
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
【讨论】: