Oracle SQL Developer 中的 Excel 日期字段导入问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6066780/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 10:38:48  来源:igfitidea点击:

Excel Date Field Import Problem in Oracle SQL Developer

sqloracleexceltimestamporacle-sqldeveloper

提问by msbyuva

I have an Excel file (which has data imported from Oracle 10G Database) one of the fields is a Date Filed which has values like 28-JAN-11 03.25.11.000000000 PM ( Date field is Oracle Time Stamp(6) in Database )

我有一个 Excel 文件(其中包含从 Oracle 10G 数据库导入的数据)其中一个字段是 Date Filed,其值类似于 28-JAN-11 03.25.11.000000000 PM(日期字段是数据库中的 Oracle Time Stamp(6))

When I am trying to Import that Excel file to another Oracle 10 G database (for another database/application), I get an error because the data field is not being recognized by Oracle 10G --> Import is being done by ORACLE SQL Developer (Table (field) has TIMESTAMP(6) as the datatype)

当我尝试将该 Excel 文件导入另一个 Oracle 10 G 数据库(用于另一个数据库/应用程序)时,出现错误,因为 Oracle 10G 无法识别数据字段 --> ORACLE SQL Developer 正在执行导入(表(字段)具有 TIMESTAMP(6) 作为数据类型)

How can I import that field? For time being I made the TIMESTAMP to VARCHAR2 and its working but I could not convert that to Date field again in C# CODE ( it says not a valid date type).

如何导入该字段?暂时我将 TIMESTAMP 设为 VARCHAR2 并使其正常工作,但我无法在 C# CODE 中再次将其转换为 Date 字段(它表示不是有效的日期类型)。

采纳答案by DCookie

You likely need to change your SQL Developer settings.

您可能需要更改 SQL Developer 设置。

Tools->Preferences->Database->NLS

Modify the Timestamp Format field to conform to the data format in your Excel spreadsheet. Not how it appears in the first database, but what it looks like in your spreadsheet. For example, in my instance, the data in Excel was:

修改时间戳格式字段以符合 Excel 电子表格中的数据格式。不是它在第一个数据库中的显示方式,而是它在电子表格中的外观。例如,在我的例子中,Excel 中的数据是:

ID  DT
1   05/19/2011 10:16 PM

I changed the format in preferences to MM/DD/YYYY HH:MI AM

我将首选项中的格式更改为 MM/DD/YYYY HH:MI AM

and was able to import successfully, after initially getting the same error you reported before changing preferences.

并且在最初收到您在更改首选项之前报告的相同错误之后能够成功导入。

You may want to change the way your data is imported into Excel originally if you need more precision from your time values.

如果您需要更精确的时间值,您可能希望更改最初将数据导入 Excel 的方式。

回答by Palani Chockalingam

During the import wizard process (column definition screen), select the date type field on the left panel under 'Source Data Columns' and type in the expected format in the 'Format' text field. For example, MM/DD/YYYY or whatever the date format is in your import file for that field.

在导入向导过程中(列定义屏幕),在“源数据列”下的左侧面板上选择日期类型字段,并在“格式”文本字段中输入预期格式。例如,MM/DD/YYYY 或该字段的导入文件中的任何日期格式。