# Oracle

> 英文标题：Oracle
> 官网原文：https://typeorm.io/docs/drivers/oracle
> 文档版本：TypeORM v1.1
> 体例：英文原文（EN）与中文译文（ZH）逐块并列，共 12 块

---

<!-- EN -->
# Oracle

<!-- ZH -->
# Oracle

<!-- EN -->
## Installation

<!-- ZH -->
## 安装

<!-- EN -->
```shell
npm install oracledb
```

<!-- ZH -->
```shell
npm install oracledb
```

<!-- EN -->
By default, the [oracledb](https://github.com/oracle/node-oracledb) uses the "thin mode" to connect. To enable the "thick mode", you need to follow the installation instructions from their [user guide](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html).

<!-- ZH -->
默认情况下，[oracledb](https://github.com/oracle/node-oracledb) 使用"thin 模式"连接。要启用"thick 模式"，你需要按照他们[用户指南](https://node-oracledb.readthedocs.io/en/latest/user_guide/installation.html)中的安装说明操作。

<!-- EN -->
## Data Source Options

<!-- ZH -->
## 数据源选项

<!-- EN -->
See [Data Source Options](https://typeorm.io/docs/data-source/data-source-options) for the common data source options.

<!-- ZH -->
通用数据源选项请参阅[数据源选项](https://typeorm.io/docs/data-source/data-source-options)。

<!-- EN -->
* `sid` - The System Identifier (SID) identifies a specific database instance. For example, "sales".
* `serviceName` - The Service Name is an identifier of a database service. For example, `sales.us.example.com`.

<!-- ZH -->
* `sid` - 系统标识符（SID）用于标识一个特定的数据库实例。例如 "sales"。
* `serviceName` - 服务名是数据库服务的标识符。例如 `sales.us.example.com`。

<!-- EN -->
## Column Types

<!-- ZH -->
## 列类型

<!-- EN -->
`char`, `nchar`, `nvarchar2`, `varchar2`, `long`, `raw`, `long raw`, `number`, `numeric`, `float`, `dec`, `decimal`, `integer`, `int`, `smallint`, `real`, `double precision`, `date`, `timestamp`, `timestamp with time zone`, `timestamp with local time zone`, `interval year to month`, `interval day to second`, `bfile`, `blob`, `clob`, `nclob`, `rowid`, `urowid`

<!-- ZH -->
`char`、`nchar`、`nvarchar2`、`varchar2`、`long`、`raw`、`long raw`、`number`、`numeric`、`float`、`dec`、`decimal`、`integer`、`int`、`smallint`、`real`、`double precision`、`date`、`timestamp`、`timestamp with time zone`、`timestamp with local time zone`、`interval year to month`、`interval day to second`、`bfile`、`blob`、`clob`、`nclob`、`rowid`、`urowid`

<!-- EN -->
## Oracle-specific behavior

<!-- ZH -->
## Oracle 专属行为

<!-- EN -->
### Custom `UPDATE RETURNING` clauses

<!-- ZH -->
### 自定义 `UPDATE RETURNING` 子句

<!-- EN -->
When an update, soft-delete or restore query uses a SQL string such as `.returning('"version" INTO :version')` with an output bind, `UpdateResult.raw` contains the driver's output binds. For example, if one row returns version `2`, the raw result is `[[2]]`. TypeORM cannot map these binds to entity columns, so entities supplied to `whereEntity()` are refreshed with a separate `SELECT` by primary key instead (unless `updateEntity(false)` is set).

<!-- ZH -->
当 update、soft-delete 或 restore 查询使用了带输出绑定的 SQL 字符串，例如 `.returning('"version" INTO :version')` 时，`UpdateResult.raw` 中包含驱动的输出绑定值。例如，如果有一行返回 version `2`，raw 结果就是 `[[2]]`。TypeORM 无法把这些绑定值映射到实体列，因此传给 `whereEntity()` 的实体会改为通过一条单独的按主键 `SELECT` 来刷新（除非设置了 `updateEntity(false)`）。
