【问题标题】:Batch file to connect postgres in windows在windows中连接postgres的批处理文件
【发布时间】:2017-11-24 11:19:32
【问题描述】:

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

【问题讨论】:

    标签: postgresql batch-file postgresql-9.4


    【解决方案1】:

    你可以只批量管道命令,像这样。

    (
    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 
    

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 1970-01-01
      • 2012-07-27
      • 2018-09-18
      • 2018-02-20
      • 1970-01-01
      • 2012-04-06
      • 2012-12-13
      • 1970-01-01
      相关资源
      最近更新 更多