psql执行一个sql命令

最近更新时间: 2024-06-12 15:06:00

  • 显示标题

     [tbase@VM_0_29_centos root]$ psql -h 172.16.0.29 -p 15432 -U tbase -d postgres -c "select count(1) from pg_class"
      count 
     -------
        317
     (1 row)
  • 不显示标题

     [tbase@VM_0_29_centos root]$ psql -h 172.16.0.29 -p 15432 -U tbase -d postgres -t -c  "select count(1) from pg_class"  
        317