问题
I'm trying to insert records with YYYY-MM-DD HH:MM:SS
format into Oracle from Netezza, but I'm getting invalid date type.
How can I accomplish this one?
CREATE TABLE AM_PROGRAM_TUNING_EVENT_TMP1
(
ST TIMESTAMP,
ET TIMESTAMP,
MAS_DIV_KEY INTEGER NOT NULL,
SBSC_GUID_KEY INTEGER NOT NULL,
STN_KEY INTEGER NOT NULL
);
INSERT INTO AM_PROGRAM_TUNING_EVENT_TMP1 VALUES('2012-03-28 11:10:00','2012-03-28 11:30:00',1,3636815,151);
回答1:
INSERT INTO AM_PROGRAM_TUNING_EVENT_TMP1
VALUES(TO_DATE('2012-03-28 11:10:00','yyyy/mm/dd hh24:mi:ss'));
http://www.sqlfiddle.com/#!4/22115/1
回答2:
Use TO_TIMESTAMP function
TO_TIMESTAMP(date_string,'YYYY-MM-DD HH24:MI:SS')
来源:https://stackoverflow.com/questions/10319935/timestamp-conversion-in-oracle-for-yyyy-mm-dd-hhmmss-format