比如我想在Linux系统下(不登陆postgres数据库)执行 select * from table ; 我主要是想在Linux下写个脚本自动执行postgres命令再拷贝出来?但小弟不知道如何操作,请各位指点一下,谢谢.

解决方案 »

  1.   


    自己参考改一下!C:\Program Files\PostgreSQL\8.3\bin>psql -Uroot -dt_girl -c "select * from test"用户 root 密码:
     id | username
    ----+----------
      1 | love
      2 | hate
    (2 笔资料列)
      

  2.   

    我用的postgres 7 的版本,发现命令执行不了,但在8的版本就可以,提示如下:pc2phone=> select sum((truncate(fcall_time/60)+1)) as call from t_prepaid_history;
    ERROR:  Function 'truncate(int4)' does not exist
            Unable to identify a function that satisfies the given argument types
            You may need to add explicit typecasts
    pc2phone=> select sum(trunc(fcall_time/60)+1) from t_prepaid_history;
    ERROR:  Function 'trunc(int4)' does not exist
            Unable to identify a function that satisfies the given argument types
            You may need to add explicit typecasts
    请问我应该用哪一个函数来算出这个结果,谢谢.
      

  3.   

    /usr/local/pgsql/bin/psql -Uroot -ddatabase -c "select sum((truncate(fcall_time/60)+1)) as call from t_prepaid_history"但本身那条语句就执行不到,请问应该用哪个函数,谢谢.