OceanBase Connector/NET interacts with the database based on the MySQL protocol and extends Oracle-specific types in Oracle mode.
Mode description
- Oracle mode: Provides
OracleDbTypeand Oracle-compatible types (such asVarchar2,TimeStampTZ, andRefCursor). - MySQL mode: Follows the MySQL protocol type system and is used in the same way as MySqlConnector.
Note
In the following text, ColumnType refers to the FieldType in the column definition of the MySQL protocol. In Oracle mode, some types are mapped to extended protocol type values (such as 200~211) of OceanBase.
Protocol-layer ColumnType comparison (MySQL protocol)
| Protocol value | MySQL FieldType | Oracle mode type | MySQL mode description |
|---|---|---|---|
| 1 | TINYINT | TINYINT | Integer (1 byte) |
| 2 | SMALLINT | SMALLINT | Integer (2 bytes) |
| 3 | INTEGER | NUMBER | INT |
| 4 | FLOAT | BINARY_FLOAT | FLOAT |
| 5 | DOUBLE | BINARY_DOUBLE | DOUBLE |
| 8 | BIGINT | BIGINT | BIGINT |
| 10 | DATE | DATE | DATE |
| 11 | TIME | - | TIME |
| 12 | DATETIME | DATETIME | DATETIME |
| 15 | VARCHAR | VARCHAR | VARCHAR |
| 16 | BIT | BIT | BIT |
| 245 | JSON | - | JSON |
| 246 | NEWDECIMAL | OBDECIMAL | DECIMAL |
| 249 | TINYBLOB | - | TINYBLOB |
| 250 | MEDIUMBLOB | - | MEDIUMBLOB |
| 251 | LONGBLOB | - | LONGBLOB |
| 252 | BLOB | - | BLOB |
| 253 | VARSTRING | VARCHAR2 | VAR_STRING |
| 254 | STRING | STRING | CHAR/BINARY |
| 255 | GEOMETRY | - | GEOMETRY |
Extended protocol types in Oracle mode
| Protocol value | Oracle extended type | Description |
|---|---|---|
| 200 | TIMESTAMP_TZ | TIMESTAMP WITH TIME ZONE |
| 201 | TIMESTAMP_LTZ | TIMESTAMP WITH LOCAL TIME ZONE |
| 202 | TIMESTAMP_NANO | High-precision timestamp |
| 203 | RAW | RAW binary type |
| 204 | INTERVALYM | INTERVAL YEAR TO MONTH |
| 205 | INTERVALDS | INTERVAL DAY TO SECOND |
| 206 | NUMBER_FLOAT | NUMBER_FLOAT (protocol Unknown) |
| 207 | NVARCHAR2 | NVARCHAR2 |
| 208 | NCHAR | NCHAR |
| 209 | ROWID | UROWID/ROWID |
| 210 | ORACLE_BLOB | Oracle BLOB |
| 211 | ORACLE_CLOB | Oracle CLOB |
Supported OracleDbType types (Oracle mode)
| OracleDbType | Corresponding Oracle type | Support |
|---|---|---|
| BinaryFloat | BINARY_FLOAT | Supported |
| BinaryDouble | BINARY_DOUBLE | Supported |
| Blob | BLOB | Supported |
| Boolean | BOOLEAN | Supported |
| Char | CHAR | Supported |
| Clob | CLOB | Supported |
| Date | DATE | Supported |
| Decimal | NUMBER | Supported |
| Double | FLOAT(8-byte) | Supported |
| Int16 / Int32 / Int64 | INTEGER | Supported |
| IntervalDS | INTERVAL DAY TO SECOND | Supported |
| IntervalYM | INTERVAL YEAR TO MONTH | Supported |
| NChar | NCHAR | Supported |
| NVarchar2 | NVARCHAR2 | Supported |
| Raw | RAW | Supported |
| RefCursor | REF CURSOR | Supported (in stored procedure scenarios) |
| Single | FLOAT(4-byte) | Supported |
| TimeStamp | TIMESTAMP | Supported |
| TimeStampLTZ | TIMESTAMP WITH LOCAL TIME ZONE | Supported |
| TimeStampTZ | TIMESTAMP WITH TIME ZONE | Supported |
| Varchar2 | VARCHAR2 | Supported |
Common parameter type mapping (Oracle mode)
| .NET Type | DbType | OracleDbType (default) |
|---|---|---|
bool |
Boolean |
Boolean |
byte |
Byte |
Byte |
byte[] |
Binary |
Raw |
short |
Int16 |
Int16 |
int |
Int32 |
Int32 |
long |
Int64 |
Int64 |
float |
Single |
Single |
double |
Double |
Double |
decimal |
Decimal |
Decimal |
string |
String |
Varchar2 |
DateTime |
DateTime |
TimeStamp |
DateTimeOffset |
DateTimeOffset |
TimeStampTZ |
TimeSpan |
Object |
IntervalDS |
Guid |
Guid |
Blob |
Type description in MySQL mode
In MySQL mode, the behavior of types is consistent with MySqlConnector. The following points are highlighted:
- Numeric, string, and date/time types are parsed based on the MySQL protocol field types.
- Types such as
JSON,BLOB, andGEOMETRYare processed based on MySQL semantics. - Parameter binding does not use
OracleDbType. Instead, use .NET types or the genericDbType.
Notice
The parameter binding systems in Oracle mode and MySQL mode are different. In Oracle mode, we recommend that you explicitly set OracleDbType. In MySQL mode, we recommend that you follow the parameter rules of MySqlConnector.