我想將文本中的一列數據更改爲時間戳類型。我的數據中沒有時區。我的數據格式是28-03-17 17:22,包括時間和日期,但沒有時區。換句話說,我所有的數據都在同一時區。我該怎麼做?postgreSQL將列數據類型更改爲不帶時區的時間戳
我嘗試了以下多種方法,但我仍然找不到正確的方法。希望您能夠幫助我。
當然,如果我的麻煩可以解決,我可以建立一個新表格。
alter table AB
alter create_time type TIMESTAMP;
ERROR: column "create_time" cannot be cast automatically to type timestamp without time zone
HINT: You might need to specify "USING create_time::timestamp without time zone".
********** Error **********
ERROR: column "create_time" cannot be cast automatically to type timestamp without time zone
SQL state: 42804
Hint: You might need to specify "USING create_time::timestamp without time zone".
alter table AB
alter create_time type TIMESTAMP without time zone;
ERROR: column "create_time" cannot be cast automatically to type timestamp without time zone
HINT: You might need to specify "USING create_time::timestamp without time zone".
********** Error **********
ERROR: column "create_time" cannot be cast automatically to type timestamp without time zone
SQL state: 42804
Hint: You might need to specify "USING create_time::timestamp without time zone".
alter table AB
alter create_time::without time zone type TIMESTAMP;
ERROR: syntax error at or near "::"
LINE 2: alter create_time::without time zone type TIMESTAM
^
********** Error **********
ERROR: syntax error at or near "::"
SQL state: 42601
Character: 50
alter table AB
alter create_time UTC type TIMESTAMP;
ERROR: syntax error at or near "UTC"
LINE 2: alter create_time UTC type TIMESTAMP;
^
********** Error **********
ERROR: syntax error at or near "UTC"
SQL state: 42601
Character: 50
作爲一般規則,請在您的問題中包含任何相關的錯誤消息。如果沒有錯誤,請提及*爲什麼*您認爲它沒有按預期工作。說這是「不正確的做法」不是很有幫助或者不夠詳細。 –
添加了所有錯誤。請檢查一下。謝謝。 – Amy
閱讀錯誤信息和您的代碼:'使用create_time :: timestamp without time zone'與您的代碼:'create_time :: without time zone type TIMESTAMP;' –