下表列出 Oracle 数据类型及其与 OracleDataReader 的映射。
| Oracle 数据类型 | 由 OracleDataReader.GetValue 返回的 .NET Framework 数据类型 | 由 OracleDataReader.GetOracleValue 返回的 OracleClient 数据类型 | Remarks(备注) |
|---|---|---|---|
| BFILE | Byte[] | OracleBFile | |
| BLOB | Byte[] | OracleLob | |
| CHAR | String | OracleString | |
| CLOB | String | OracleLob | |
| DATE | DateTime | OracleDateTime | |
| FLOAT | Decimal | OracleNumber | 此数据类型是 NUMBER 数据类型的别名,其设计目的是使 OracleDataReader 返回 System.Decimal 或 OracleNumber,而不是浮点值。 使用该 .NET Framework 数据类型可能导致溢出。 |
| INTEGER | Decimal | OracleNumber | 此数据类型是 NUMBER(38) 数据类型的别名,其设计目的是使 OracleDataReader 返回 System.Decimal 或 OracleNumber,而不是整数值。 使用该 .NET Framework 数据类型可能导致溢出。 |
| INTERVAL YEAR TO MONTH | Int32 | OracleMonthSpan | |
| INTERVAL DAY TO SECOND | TimeSpan | OracleTimeSpan | |
| LONG | String | OracleString | |
| LONG RAW | Byte[] | OracleBinary | |
| NCHAR | String | OracleString | |
| NCLOB | String | OracleLob | |
| NUMBER | Decimal | OracleNumber | 使用该 .NET Framework 数据类型可能导致溢出。 |
| NVARCHAR2 | String | OracleString | |
| RAW | Byte[] | OracleBinary | |
| REF CURSOR | OracleDataReader 对象不支持 Oracle REF CURSOR 数据类型。 | ||
| ROWID | String | OracleString | |
| TIMESTAMP | DateTime | OracleDateTime | |
| TIMESTAMP WITH LOCAL TIME ZONE | DateTime | OracleDateTime | |
| TIMESTAMP WITH TIME ZONE | DateTime | OracleDateTime | |
| UNSIGNED INTEGER | Number | OracleNumber | 此数据类型是 NUMBER(38) 数据类型的别名,其设计目的是使 OracleDataReader 返回 System.Decimal 或 OracleNumber,而不是无符号整数值。 使用该 .NET Framework 数据类型可能导致溢出。 |
| VARCHAR2 | String | OracleString |
下表列出了在将数据类型作为参数绑定时使用的 Oracle 数据类型和 .NET Framework 数据类型(System.Data.DbType and OracleType)。
| Oracle 数据类型 | 要绑定为参数的 DbType 枚举 | 要绑定为参数的 OracleType 枚举 | Remarks(备注) |
|---|---|---|---|
| BFILE | BFile | Oracle only allows binding a BFILE as a BFILE parameter. The .NET Data Provider for Oracle does not automatically construct one for you if you attempt to bind a non-BFILE value, such as byte[] or OracleBinary. | |
| BLOB | Blob | Oracle only allows binding a BLOB as a BLOB parameter. The .NET Data Provider for Oracle does not automatically construct one for you if you attempt to bind a non-BLOB value, such as byte[] or OracleBinary. | |
| CHAR | AnsiStringFixedLength | Char | |
| CLOB | Clob | Oracle only allows binding a CLOB as a CLOB parameter. The .NET Data Provider for Oracle does not automatically construct one for you if you attempt to bind a non-CLOB value, such as System.String or OracleString. | |
| DATE | DateTime | DateTime | |
| FLOAT | Single, Double, Decimal | Float, Double, Number | Size determines the System.Data.DBType and OracleType. |
| INTEGER | SByte, Int16, Int32, Int64, Decimal | SByte, Int16, Int32, Number | Size determines the System.Data.DBType and OracleType. |
| INTERVAL YEAR TO MONTH | Int32 | IntervalYearToMonth | OracleType is only available when using both Oracle 9i client and server software. |
| INTERVAL DAY TO SECOND | Object | IntervalDayToSecond | OracleType is only available when using both Oracle 9i client and server software. |
| LONG | AnsiString | LongVarChar | |
| LONG RAW | Binary | LongRaw | |
| NCHAR | StringFixedLength | NChar | |
| NCLOB | NClob | Oracle only allows binding a NCLOB as a NCLOB parameter. The .NET Data Provider for Oracle does not automatically construct one for you if you attempt to bind a non-NCLOB value, such as System.String or OracleString. | |
| NUMBER | VarNumeric | Number | |
| NVARCHAR2 | String | NVarChar | |
| RAW | Binary | Raw | |
| REF CURSOR | Cursor | 有关详细信息,请参阅 Oracle REF CURSOR。 | |
| ROWID | AnsiString | Rowid | |
| TIMESTAMP | DateTime | Timestamp | 只有在同时使用 Oracle 9i 客户端和服务器软件时,OracleType 才可用。 |
| TIMESTAMP WITH LOCAL TIME ZONE | DateTime | TimestampLocal | 只有在同时使用 Oracle 9i 客户端和服务器软件时,OracleType 才可用。 |
| TIMESTAMP WITH TIME ZONE | DateTime | TimestampWithTz | 只有在同时使用 Oracle 9i 客户端和服务器软件时,OracleType 才可用。 |
| UNSIGNED INTEGER | Byte, UInt16, UInt32, UInt64, Decimal | Byte, UInt16, Uint32, Number | Size 确定 System.Data.DBType 和 OracleType。 |
| VARCHAR2 | AnsiString | VarChar |
由 OracleParameter 对象的 Value 属性使用的 InputOutput、Output 和 ReturnValue ParameterDirection 值为 .NET Framework 数据类型,除非输入值是 Oracle 数据类型(例如, OracleNumber or OracleString)。 这并不适用于 REF CURSOR、BFILE 或 LOB 数据类型。