2015-02-07 86 views
1

我試圖在vertica表中做一個非常簡單的INSERT,它不起作用:我的數據被忽略。Vertica插入被忽略

$ LC_ALL=C /opt/vertica/bin/vsql db user -w *** -c "SELECT * FROM footable" 
     lastFetch   | ApiPath | response 
---------------------------+---------+---------- 
2015-02-07 18:41:42.26069 | a1  | b1 
(1 row) 

$ LC_ALL=C /opt/vertica/bin/vsql db user -w *** -c "INSERT INTO footable (lastFetch, ApiPath, response) VALUES ('2015-02-07 18:19:32.435001', 'a2', 'b2')" 
OUTPUT 
-------- 
     1 
(1 row) 

$ LC_ALL=C /opt/vertica/bin/vsql db user -w *** -c "SELECT * FROM footable" 
     lastFetch   | ApiPath | response 
---------------------------+---------+---------- 
2015-02-07 18:41:42.26069 | a1  | b1 
(1 row) 

有什麼想法可能會出錯?

我試過vertica-python,結果相同。 我也試過NOW()而不是'2015-02-07 18:19:32.435001'

回答

4

默認情況下關閉自動提交:

$ vsql -c "\set" 
VERSION = 'vsql' 
AUTOCOMMIT = 'off' 
... 

或者提交更改或定義AUTOCOMMT=ON。 針對我的意見 - 第二選擇是更好:

$ vsql -v AUTOCOMMIT=on -c "\set" 
VERSION = 'vsql' 
AUTOCOMMIT = 'on' 
... 

或只是把commit INSERT語句之後:

$ vsql -c "INSER INTO whatever VALUES (...); commit;"