INSERT INTO SELECT FROM ACCESS TO ORACLE

梦想与她 提交于 2020-01-15 12:37:10

问题


I have a table in Access named TEST_DATE1 with the column TEST_DATE that is a String datatype and the records look like 20080130. yyyymmdd

I have a table in Oracle named TEST with the column TEST_DATE that is a DATE datatype and I want the records to look like 2008/01/30 yyyy/mm/dd.

I have the two tables linked and when I usually update tables between Access and Oracle I usually do a

INSERT INTO TEST
SELECT *
FROM TEST_DATE1;

How would you convert the string to a DATE using the INSERT INTO SELECT

I have tried

INSERT INTO TEST
(SELECT TO_DATE(TEST_DATE, 'yyyy/mm/dd'))
FROM TEST_DATE1;

Thanks!


回答1:


To move the records to Oracle, converting a string to a date:

INSERT INTO test (test_date)
SELECT TO_DATE(test_date, 'YYYYMMDD')
FROM test_date1

Once it's in Oracle stored as a date, you can retrieve it in any format you like:

SELECT TO_CHAR(test_date, 'YYYY/MM/DD') as test_date
FROM test;


来源:https://stackoverflow.com/questions/10391389/insert-into-select-from-access-to-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!