oracle 在sql developer中导入表时的日期格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36060290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Date format while importing table in sql developer
提问by sreekem bose
I am trying to import details from a csv file which i am creating through BI Publisher query from a table.
我正在尝试从我通过 BI Publisher 查询从表中创建的 csv 文件中导入详细信息。
In the query , I have a date formatted column:
在查询中,我有一个日期格式的列:
effective_start_date
1951-01-01T00:00:00.000+00:00
1901-01-01T00:00:00.000+00:00
Now when i am importing the entire table in excel. How should i import in sql developer in such a way that the date format comes as 'DD-MON-YYYY'
现在,当我在 excel 中导入整个表格时。我应该如何在 sql developer 中以日期格式为“DD-MON-YYYY”的方式导入
Right now few records for date are getting imprted in table as null !
现在很少有日期记录在表中被输入为 null !
Also my targer column format is not an editable screen in sql devleoper
此外,我的目标列格式不是 sql devleoper 中的可编辑屏幕
回答by MT0
Oracle Setup:
甲骨文设置:
CREATE TABLE TEST_LOAD ( id INT, effective_start_date DATE );
CSV:
CSV:
ID,EFFECTIVE_START_DATE
1,1951-01-01T00:00:00.000+00:00
2,1901-01-01T00:00:00.000+00:00
Import (SQL Developer 4.1.0.19):
导入(SQL Developer 4.1.0.19):
- In the connections panel, right-click on the table name and choose "Import Data..."
- Browse to the csv file then click "Next >".
- Select "Insert Script" as the insert method and click "Next >".
- Click "Next >" to accept the default selected columns.
- In the column definitions,
EFFECTIVE_START_DATE
will have a warning triangle next to it and will say "Data is not compatible with column definition...". Change the format toYYYY-MM-DD"T00:00:00.000+00:00"
then click "Next >" - Click "Finish"
- This should bring up a dialog saying "Task successful and sent to worksheet."
- Optionally: Do a find/replace on the script replacing
to_date\(('.*?'), '.*?'\)
withCAST( TO_TIMESTAMP_TZ( $1, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM' ) AS DATE )
and select the regular expression option and do a "Replace all". - Run the script (press
F5
).
- 在连接面板中,右键单击表名称并选择“导入数据...”
- 浏览到 csv 文件,然后单击“下一步 >”。
- 选择“插入脚本”作为插入方法,然后单击“下一步>”。
- 单击“下一步 >”以接受默认选择的列。
- 在列定义中,
EFFECTIVE_START_DATE
旁边会有一个警告三角形,并会显示“数据与列定义不兼容...”。更改格式,YYYY-MM-DD"T00:00:00.000+00:00"
然后单击“下一步>” - 点击“完成”
- 这应该会弹出一个对话框,提示“任务成功并发送到工作表”。
- 可选:做一个查找/上的脚本替换替换
to_date\(('.*?'), '.*?'\)
与CAST( TO_TIMESTAMP_TZ( $1, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM' ) AS DATE )
和选择正则表达式选项,并做了“全部替换”。 - 运行脚本(按
F5
)。
Output
输出
SELECT * FROM TEST_LOAD;
ID EFFECTIVE_START_DATE
-- --------------------
1 1951-01-01 00:00:00
2 1901-01-01 00:00:00
(The format of the date will depend on your NLS settings.)
(日期格式取决于您的 NLS 设置。)