當我運行我的命令:PSQL運行SQL文件,結果
psql -h localhost -p 5432 -U meee -d my_db -f sqltest.sql
它顯示:
CREATE VIEW
ALTER TABLE
但是我希望它告訴我,就像pgAdmin的表現出來(對於exmpl:查詢是在45毫秒內成功執行,但不返回結果)
當我運行我的命令:PSQL運行SQL文件,結果
psql -h localhost -p 5432 -U meee -d my_db -f sqltest.sql
它顯示:
CREATE VIEW
ALTER TABLE
但是我希望它告訴我,就像pgAdmin的表現出來(對於exmpl:查詢是在45毫秒內成功執行,但不返回結果)
在sqltest.sql的開頭添加命令\ timing並且您將看到每個命令的時間
例如script.sql: \timing select 2 ; select 1; create table tablax(i int);
,或者如果你想讓所有時間都弗洛姆德腳本,直到結束的開始時,添加一些命令scritp 的開始: create temp table tab (time1 time,time2 time); insert into tab (time1) select now()::time;
末: update tab set time2=now()::time; select time2-time1 as time_Elapsed from tab;
例如:
create temp table tab (time1 time,time2 time);
insert into tab (time1) select now()::time;
... 腳本代碼
... update tab set time2=now()::time; select time2-time1 as time_Elapsed from tab;
使用a
PSQL命令參數:
psql -h localhost -p 5432 -U meee -d my_db -af sqltest.sql
https://www.postgresql.org/docs/current/static/app-psql.html
和地點\timing on
頂部您的腳本
'\ timing on':https://www.postgresql.org/docs/current/static/app-psql.html –
哦謝謝。但沒有任何改變 – Meegh