:ref:`SQL Server Transaction Isolation <mssql_isolation_level>`
- :ref:`Oracle Transaction Isolation <oracle_isolation_level>`
+ :ref:`Oracle Database Transaction Isolation <oracle_isolation_level>`
:ref:`session_transaction_isolation` - for the ORM
Using Server Side Cursors (a.k.a. stream results)
-------------------------------------------------
-Some backends feature explicit support for the concept of "server
-side cursors" versus "client side cursors". A client side cursor here
-means that the database driver fully fetches all rows from a result set
-into memory before returning from a statement execution. Drivers such as
-those of PostgreSQL and MySQL/MariaDB generally use client side cursors
-by default. A server side cursor, by contrast, indicates that result rows
-remain pending within the database server's state as result rows are consumed
-by the client. The drivers for Oracle generally use a "server side" model,
-for example, and the SQLite dialect, while not using a real "client / server"
-architecture, still uses an unbuffered result fetching approach that will
-leave result rows outside of process memory before they are consumed.
+Some backends feature explicit support for the concept of "server side cursors"
+versus "client side cursors". A client side cursor here means that the
+database driver fully fetches all rows from a result set into memory before
+returning from a statement execution. Drivers such as those of PostgreSQL and
+MySQL/MariaDB generally use client side cursors by default. A server side
+cursor, by contrast, indicates that result rows remain pending within the
+database server's state as result rows are consumed by the client. The drivers
+for Oracle Database generally use a "server side" model, for example, and the
+SQLite dialect, while not using a real "client / server" architecture, still
+uses an unbuffered result fetching approach that will leave result rows outside
+of process memory before they are consumed.
.. topic:: What we really mean is "buffered" vs. "unbuffered" results
~~~~~~~~~~~~~~~
The feature is enabled for all backend included in SQLAlchemy that support
-RETURNING, with the exception of Oracle for which both the cx_Oracle and
-OracleDB drivers offer their own equivalent feature. The feature normally takes
-place when making use of the :meth:`_dml.Insert.returning` method of an
-:class:`_dml.Insert` construct in conjunction with :term:`executemany`
-execution, which occurs when passing a list of dictionaries to the
-:paramref:`_engine.Connection.execute.parameters` parameter of the
-:meth:`_engine.Connection.execute` or :meth:`_orm.Session.execute` methods (as
-well as equivalent methods under :ref:`asyncio <asyncio_toplevel>` and
-shorthand methods like :meth:`_orm.Session.scalars`). It also takes place
-within the ORM :term:`unit of work` process when using methods such as
-:meth:`_orm.Session.add` and :meth:`_orm.Session.add_all` to add rows.
+RETURNING, with the exception of Oracle Database for which both the
+python-oracledb and cx_Oracle drivers offer their own equivalent feature. The
+feature normally takes place when making use of the
+:meth:`_dml.Insert.returning` method of an :class:`_dml.Insert` construct in
+conjunction with :term:`executemany` execution, which occurs when passing a
+list of dictionaries to the :paramref:`_engine.Connection.execute.parameters`
+parameter of the :meth:`_engine.Connection.execute` or
+:meth:`_orm.Session.execute` methods (as well as equivalent methods under
+:ref:`asyncio <asyncio_toplevel>` and shorthand methods like
+:meth:`_orm.Session.scalars`). It also takes place within the ORM :term:`unit
+of work` process when using methods such as :meth:`_orm.Session.add` and
+:meth:`_orm.Session.add_all` to add rows.
For SQLAlchemy's included dialects, support or equivalent support is currently
as follows:
* SQL Server - all supported SQL Server versions [#]_
* MariaDB - supported for MariaDB versions 10.5 and above
* MySQL - no support, no RETURNING feature is present
-* Oracle - supports RETURNING with executemany using native cx_Oracle / OracleDB
- APIs, for all supported Oracle versions 9 and above, using multi-row OUT
+* Oracle Database - supports RETURNING with executemany using native python-oracledb / cx_Oracle
+ APIs, for all supported Oracle Databae versions 9 and above, using multi-row OUT
parameters. This is not the same implementation as "executemanyvalues", however has
the same usage patterns and equivalent performance benefits.
:class:`~sqlalchemy.schema.Sequence` object, which is considered to be a
special case of "column default". It only has an effect on databases which have
explicit support for sequences, which among SQLAlchemy's included dialects
-includes PostgreSQL, Oracle, MS SQL Server, and MariaDB. The
+includes PostgreSQL, Oracle Database, MS SQL Server, and MariaDB. The
:class:`~sqlalchemy.schema.Sequence` object is otherwise ignored.
.. tip::
In the above example, ``CREATE TABLE`` for PostgreSQL will make use of the
``SERIAL`` datatype for the ``cart_id`` column, and the ``cart_id_seq``
-sequence will be ignored. However on Oracle, the ``cart_id_seq`` sequence
-will be created explicitly.
+sequence will be ignored. However on Oracle Database, the ``cart_id_seq``
+sequence will be created explicitly.
.. tip::
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. note:: The following technique is known to work only with the PostgreSQL
- database. It does not work with Oracle.
+ database. It does not work with Oracle Database.
The preceding sections illustrate how to associate a :class:`.Sequence` with a
:class:`_schema.Column` as the **Python side default generator**::
:ref:`postgresql_sequences` - in the PostgreSQL dialect documentation
- :ref:`oracle_returning` - in the Oracle dialect documentation
+ :ref:`oracle_returning` - in the Oracle Database dialect documentation
.. _computed_ddl:
* PostgreSQL as of version 12
-* Oracle - with the caveat that RETURNING does not work correctly with UPDATE
- (a warning will be emitted to this effect when the UPDATE..RETURNING that
- includes a computed column is rendered)
+* Oracle Database - with the caveat that RETURNING does not work correctly with
+ UPDATE (a warning will be emitted to this effect when the UPDATE..RETURNING
+ that includes a computed column is rendered)
* Microsoft SQL Server
* PostgreSQL as of version 10.
-* Oracle as of version 12. It also supports passing ``always=None`` to
+* Oracle Database as of version 12. It also supports passing ``always=None`` to
enable the default generated mode and the parameter ``on_null=True`` to
specify "ON NULL" in conjunction with a "BY DEFAULT" identity column.
as if this disconnect should cause the entire connection pool to be invalidated
or not.
-For example, to add support to consider the Oracle error codes
-``DPY-1001`` and ``DPY-4011`` to be handled as disconnect codes, apply an
-event handler to the engine after creation::
+For example, to add support to consider the Oracle Database driver error codes
+``DPY-1001`` and ``DPY-4011`` to be handled as disconnect codes, apply an event
+handler to the engine after creation::
import re
from sqlalchemy import create_engine
- engine = create_engine("oracle://scott:tiger@dnsname")
+ engine = create_engine(
+ "oracle+oracledb://scott:tiger@localhost:1521?service_name=freepdb1"
+ )
@event.listens_for(engine, "handle_error")
def handle_exception(context: ExceptionContext) -> None:
if not context.is_disconnect and re.match(
- r"^(?:DPI-1001|DPI-4011)", str(context.original_exception)
+ r"^(?:DPY-1001|DPY-4011)", str(context.original_exception)
):
context.is_disconnect = True
return None
-The above error processing function will be invoked for all Oracle errors
-raised, including those caught when using the
-:ref:`pool pre ping <pool_disconnects_pessimistic>` feature for those backends
-that rely upon disconnect error handling (new in 2.0).
+The above error processing function will be invoked for all Oracle Database
+errors raised, including those caught when using the :ref:`pool pre ping
+<pool_disconnects_pessimistic>` feature for those backends that rely upon
+disconnect error handling (new in 2.0).
.. seealso::
.. autoclass:: _ConnectionFairy
.. autoclass:: _ConnectionRecord
-
or BIT values 0 and 1, some have boolean literal constants ``true`` and
``false`` while others dont. For this datatype, :class:`_types.Boolean`
may render ``BOOLEAN`` on a backend such as PostgreSQL, ``BIT`` on the
-MySQL backend and ``SMALLINT`` on Oracle. As data is sent and received
-from the database using this type, based on the dialect in use it may be
-interpreting Python numeric or boolean values.
+MySQL backend and ``SMALLINT`` on Oracle Database. As data is sent and
+received from the database using this type, based on the dialect in use it
+may be interpreting Python numeric or boolean values.
The typical SQLAlchemy application will likely wish to use primarily
"CamelCase" types in the general case, as they will generally provide the best
.. autoclass:: VARCHAR
-
-
.. automodule:: sqlalchemy.dialects.oracle.base
-Oracle Data Types
------------------
+Oracle Database Data Types
+--------------------------
-As with all SQLAlchemy dialects, all UPPERCASE types that are known to be
-valid with Oracle are importable from the top level dialect, whether
-they originate from :mod:`sqlalchemy.types` or from the local dialect::
+As with all SQLAlchemy dialects, all UPPERCASE types that are known to be valid
+with Oracle Database are importable from the top level dialect, whether they
+originate from :mod:`sqlalchemy.types` or from the local dialect::
from sqlalchemy.dialects.oracle import (
BFILE,
.. versionadded:: 1.2.19 Added :class:`_types.NCHAR` to the list of datatypes
exported by the Oracle dialect.
-Types which are specific to Oracle, or have Oracle-specific
+Types which are specific to Oracle Database, or have Oracle-specific
construction arguments, are as follows:
.. currentmodule:: sqlalchemy.dialects.oracle
A key limitation of the ``cursor.executemany()`` method as used with
all known DBAPIs is that the ``cursor`` is not configured to return
rows when this method is used. For **most** backends (a notable
- exception being the cx_Oracle, / OracleDB DBAPIs), this means that
+ exception being the python-oracledb / cx_Oracle DBAPIs), this means that
statements like ``INSERT..RETURNING`` typically cannot be used with
``cursor.executemany()`` directly, since DBAPIs typically do not
aggregate the single row from each INSERT execution together.
values as they are not included otherwise (but note any series of columns
or SQL expressions can be placed into RETURNING, not just default-value columns).
- The backends that currently support
- RETURNING or a similar construct are PostgreSQL, SQL Server, Oracle,
- and Firebird. The PostgreSQL and Firebird implementations are generally
- full featured, whereas the implementations of SQL Server and Oracle
- have caveats. On SQL Server, the clause is known as "OUTPUT INSERTED"
- for INSERT and UPDATE statements and "OUTPUT DELETED" for DELETE statements;
- the key caveat is that triggers are not supported in conjunction with this
- keyword. On Oracle, it is known as "RETURNING...INTO", and requires that the
- value be placed into an OUT parameter, meaning not only is the syntax awkward,
- but it can also only be used for one row at a time.
+ The backends that currently support RETURNING or a similar construct
+ are PostgreSQL, SQL Server, Oracle Database, and Firebird. The
+ PostgreSQL and Firebird implementations are generally full featured,
+ whereas the implementations of SQL Server and Oracle have caveats. On
+ SQL Server, the clause is known as "OUTPUT INSERTED" for INSERT and
+ UPDATE statements and "OUTPUT DELETED" for DELETE statements; the key
+ caveat is that triggers are not supported in conjunction with this
+ keyword. In Oracle Database, it is known as "RETURNING...INTO", and
+ requires that the value be placed into an OUT parameter, meaning not
+ only is the syntax awkward, but it can also only be used for one row at
+ a time.
SQLAlchemy's :meth:`.UpdateBase.returning` system provides a layer of abstraction
on top of the RETURNING systems of these backends to provide a consistent
.. seealso::
:ref:`session_object_states`
-
:doc:`PostgreSQL <dialects/postgresql>` |
:doc:`MySQL and MariaDB <dialects/mysql>` |
:doc:`SQLite <dialects/sqlite>` |
- :doc:`Oracle <dialects/oracle>` |
+ :doc:`Oracle Database <dialects/oracle>` |
:doc:`Microsoft SQL Server <dialects/mssql>`
:doc:`More Dialects ... <dialects/index>`
* :doc:`Error Message Guide <errors>` - Explanations of many SQLAlchemy Errors
* :doc:`Complete table of of contents <contents>`
* :ref:`Index <genindex>`
-
The feature also has conditional support to work in conjunction with
primary key columns. For backends that have RETURNING support
-(including Oracle, SQL Server, MariaDB 10.5, SQLite 3.35) a
+(including Oracle Database, SQL Server, MariaDB 10.5, SQLite 3.35) a
SQL expression may be assigned to a primary key column as well. This allows
both the SQL expression to be evaluated, as well as allows any server side
triggers that modify the primary key value on INSERT, to be successfully
database support RETURNING or an equivalent, such as "OUTPUT inserted"; these
are SQL phrases which return a server-generated value at the same time as the
INSERT or UPDATE statement is invoked. RETURNING is currently supported
-by PostgreSQL, Oracle, MariaDB 10.5, SQLite 3.35, and SQL Server.
+by PostgreSQL, Oracle Database, MariaDB 10.5, SQLite 3.35, and SQL Server.
Case 1: non primary key, RETURNING or equivalent is supported
-------------------------------------------------------------
include functions for fetching the "last inserted id" where RETURNING
is not supported, and where RETURNING is supported SQLAlchemy will use that.
-For example, using Oracle with a column marked as :class:`.Identity`,
+For example, using Oracle Database with a column marked as :class:`.Identity`,
RETURNING is used automatically to fetch the new primary key value::
class MyOracleModel(Base):
id: Mapped[int] = mapped_column(Identity(), primary_key=True)
data: Mapped[str] = mapped_column(String(50))
-The INSERT for a model as above on Oracle looks like:
+The INSERT for a model as above on Oracle Database looks like:
.. sourcecode:: sql
For non-integer values generated by server side functions or triggers, as well
as for integer values that come from constructs outside the table itself,
including explicit sequences and triggers, the server default generation must
-be marked in the table metadata. Using Oracle as the example again, we can
+be marked in the table metadata. Using Oracle Database as the example again, we can
illustrate a similar table as above naming an explicit sequence using the
:class:`.Sequence` construct::
id: Mapped[int] = mapped_column(Sequence("my_oracle_seq"), primary_key=True)
data: Mapped[str] = mapped_column(String(50))
-An INSERT for this version of the model on Oracle would look like:
+An INSERT for this version of the model on Oracle Database would look like:
.. sourcecode:: sql
Things to know about this kind of loading include:
* The strategy emits a SELECT for up to 500 parent primary key values at a
- time, as the primary keys are rendered into a large IN expression in the
- SQL statement. Some databases like Oracle have a hard limit on how large
- an IN expression can be, and overall the size of the SQL string shouldn't
- be arbitrarily large.
+ time, as the primary keys are rendered into a large IN expression in the SQL
+ statement. Some databases like Oracle Database have a hard limit on how
+ large an IN expression can be, and overall the size of the SQL string
+ shouldn't be arbitrarily large.
* As "selectin" loading relies upon IN, for a mapping with composite primary
keys, it must use the "tuple" form of IN, which looks like ``WHERE
1 'somewidget' 5 5 'someentry' 1
In the first case, a row points to itself. Technically, a database that uses
-sequences such as PostgreSQL or Oracle can INSERT the row at once using a
-previously generated value, but databases which rely upon autoincrement-style
-primary key identifiers cannot. The :func:`~sqlalchemy.orm.relationship`
-always assumes a "parent/child" model of row population during flush, so
-unless you are populating the primary key/foreign key columns directly,
-:func:`~sqlalchemy.orm.relationship` needs to use two statements.
+sequences such as PostgreSQL or Oracle Database can INSERT the row at once
+using a previously generated value, but databases which rely upon
+autoincrement-style primary key identifiers cannot. The
+:func:`~sqlalchemy.orm.relationship` always assumes a "parent/child" model of
+row population during flush, so unless you are populating the primary
+key/foreign key columns directly, :func:`~sqlalchemy.orm.relationship` needs to
+use two statements.
In the second case, the "widget" row must be inserted before any referring
"entry" rows, but then the "favorite_entry_id" column of that "widget" row
reference a primary key column whose value has changed.
The primary platforms without referential integrity features are
MySQL when the ``MyISAM`` storage engine is used, and SQLite when the
-``PRAGMA foreign_keys=ON`` pragma is not used. The Oracle database also
+``PRAGMA foreign_keys=ON`` pragma is not used. Oracle Database also
has no support for ``ON UPDATE CASCADE``, but because it still enforces
referential integrity, needs constraints to be marked as deferrable
so that SQLAlchemy can emit UPDATE statements.
map for objects that may be referencing the one with a
mutating primary key, not throughout the database.
-As virtually all databases other than Oracle now support ``ON UPDATE CASCADE``,
-it is highly recommended that traditional ``ON UPDATE CASCADE`` support be used
-in the case that natural and mutable primary key values are in use.
-
+As virtually all databases other than Oracle Database now support ``ON UPDATE
+CASCADE``, it is highly recommended that traditional ``ON UPDATE CASCADE``
+support be used in the case that natural and mutable primary key values are in
+use.
It is *strongly recommended* that server side version counters only be used
when absolutely necessary and only on backends that support :term:`RETURNING`,
-currently PostgreSQL, Oracle, MariaDB 10.5, SQLite 3.35, and SQL Server.
+currently PostgreSQL, Oracle Database, MariaDB 10.5, SQLite 3.35, and SQL
+Server.
Programmatic or Conditional Version Counters
as :class:`_functions.count`, :class:`_functions.now`, :class:`_functions.max`,
:class:`_functions.concat` include pre-packaged versions of themselves which
provide for proper typing information as well as backend-specific SQL
-generation in some cases. The example below contrasts the SQL generation
-that occurs for the PostgreSQL dialect compared to the Oracle dialect for
+generation in some cases. The example below contrasts the SQL generation that
+occurs for the PostgreSQL dialect compared to the Oracle Database dialect for
the :class:`_functions.now` function::
>>> from sqlalchemy.dialects import postgresql
Table-valued SQL functions support a scalar representation that contains named
sub-elements. Often used for JSON and ARRAY-oriented functions as well as
functions like ``generate_series()``, the table-valued function is specified in
-the FROM clause, and is then referenced as a table, or sometimes even as
-a column. Functions of this form are prominent within the PostgreSQL database,
+the FROM clause, and is then referenced as a table, or sometimes even as a
+column. Functions of this form are prominent within the PostgreSQL database,
however some forms of table valued functions are also supported by SQLite,
-Oracle, and SQL Server.
+Oracle Database, and SQL Server.
.. seealso::
Column Valued Functions - Table Valued Function as a Scalar Column
##################################################################
-A special syntax supported by PostgreSQL and Oracle is that of referring
-towards a function in the FROM clause, which then delivers itself as a
-single column in the columns clause of a SELECT statement or other column
+A special syntax supported by PostgreSQL and Oracle Database is that of
+referring towards a function in the FROM clause, which then delivers itself as
+a single column in the columns clause of a SELECT statement or other column
expression context. PostgreSQL makes great use of this syntax for such
functions as ``json_array_elements()``, ``json_object_keys()``,
``json_each_text()``, ``json_each()``, etc.
{printsql}SELECT x
FROM json_array_elements(:json_array_elements_1) AS x
-The "column valued" form is also supported by the Oracle dialect, where
-it is usable for custom SQL functions::
+The "column valued" form is also supported by the Oracle Database dialects,
+where it is usable for custom SQL functions::
>>> from sqlalchemy.dialects import oracle
>>> stmt = select(func.scalar_strings(5).column_valued("s"))
r"""
.. dialect:: oracle
- :name: Oracle
+ :name: Oracle Database
:normal_support: 11+
:best_effort: 9+
Additionally, the :meth:`_engine.Connection.get_isolation_level` method will
raise an exception if the ``v$transaction`` view is not available due to
- permissions or other reasons, which is a common occurrence in Oracle
+ permissions or other reasons, which is a common occurrence in Oracle Database
installations.
The python-oracledb and cx_Oracle dialects attempt to call the
and not self.dialect._supports_update_returning_computed_cols
):
util.warn(
- "Computed columns don't work with Oracle UPDATE "
+ "Computed columns don't work with Oracle Database UPDATE "
"statements that use RETURNING; the value of the column "
"*before* the UPDATE takes place is returned. It is "
- "advised to not use RETURNING with an Oracle computed "
+ "advised to not use RETURNING with an Oracle Database computed "
"column. Consider setting implicit_returning to False on "
"the Table object in order to avoid implicit RETURNING "
"clauses from being generated for this Table."
raise exc.InvalidRequestError(
"Using explicit outparam() objects with "
"UpdateBase.returning() in the same Core DML statement "
- "is not supported in the Oracle dialect."
+ "is not supported in the Oracle Database dialects."
)
self._oracle_returning = True
return "RETURNING " + ", ".join(columns) + " INTO " + ", ".join(binds)
def _row_limit_clause(self, select, **kw):
- """ORacle 12c supports OFFSET/FETCH operators
+ """Oracle Database 12c supports OFFSET/FETCH operators
Use it instead subquery with row_number
"""
# https://web.archive.org/web/20090317041251/https://asktom.oracle.com/tkyte/update_cascade/index.html
if constraint.onupdate is not None:
util.warn(
- "Oracle does not contain native UPDATE CASCADE "
+ "Oracle Database does not contain native UPDATE CASCADE "
"functionality - onupdates will not be rendered for foreign "
"keys. Consider using deferrable=True, initially='deferred' "
"or triggers."
)
if generated.persisted is True:
raise exc.CompileError(
- "Oracle computed columns do not support 'stored' persistence; "
- "set the 'persisted' flag to None or False for Oracle support."
+ "Oracle Database computed columns do not support 'stored' persistence; "
+ "set the 'persisted' flag to None or False for Oracle Database support."
)
elif generated.persisted is False:
text += " VIRTUAL"
# cx_Oracle seems to occasionally leak open connections when a large
# suite it run, even if we confirm we have zero references to
# connection objects.
- # while there is a "kill session" command in Oracle,
+ # while there is a "kill session" command in Oracle Database,
# it unfortunately does not release the connection sufficiently.
_ora_drop_ignore(conn, ident)
_ora_drop_ignore(conn, "%s_ts1" % ident)
class FLOAT(sqltypes.FLOAT):
- """Oracle FLOAT.
+ """Oracle Database FLOAT.
This is the same as :class:`_sqltypes.FLOAT` except that
- an Oracle-specific :paramref:`_oracle.FLOAT.binary_precision`
+ an Oracle Database -specific :paramref:`_oracle.FLOAT.binary_precision`
parameter is accepted, and
the :paramref:`_sqltypes.Float.precision` parameter is not accepted.
- Oracle FLOAT types indicate precision in terms of "binary precision", which
- defaults to 126. For a REAL type, the value is 63. This parameter does not
- cleanly map to a specific number of decimal places but is roughly
- equivalent to the desired number of decimal places divided by 0.3103.
+ Oracle Database FLOAT types indicate precision in terms of "binary
+ precision", which defaults to 126. For a REAL type, the value is 63. This
+ parameter does not cleanly map to a specific number of decimal places but
+ is roughly equivalent to the desired number of decimal places divided by
+ 0.3103.
.. versionadded:: 2.0
r"""
Construct a FLOAT
- :param binary_precision: Oracle binary precision value to be rendered
+ :param binary_precision: Oracle Database binary precision value to be rendered
in DDL. This may be approximated to the number of decimal characters
using the formula "decimal precision = 0.30103 * binary precision".
- The default value used by Oracle for FLOAT / DOUBLE PRECISION is 126.
+ The default value used by Oracle Database for FLOAT / DOUBLE PRECISION is 126.
:param asdecimal: See :paramref:`_sqltypes.Float.asdecimal`
class DATE(_OracleDateLiteralRender, sqltypes.DateTime):
- """Provide the oracle DATE type.
+ """Provide the Oracle Database DATE type.
This type has no special Python behavior, except that it subclasses
- :class:`_types.DateTime`; this is to suit the fact that the Oracle
+ :class:`_types.DateTime`; this is to suit the fact that the Oracle Database
``DATE`` type supports a time value.
"""
class TIMESTAMP(sqltypes.TIMESTAMP):
- """Oracle implementation of ``TIMESTAMP``, which supports additional
- Oracle-specific modes
+ """Oracle Database implementation of ``TIMESTAMP``, which supports
+ additional Oracle Database-specific modes
.. versionadded:: 2.0
"""Construct a new :class:`_oracle.TIMESTAMP`.
:param timezone: boolean. Indicates that the TIMESTAMP type should
- use Oracle's ``TIMESTAMP WITH TIME ZONE`` datatype.
+ use Oracle Database's ``TIMESTAMP WITH TIME ZONE`` datatype.
:param local_timezone: boolean. Indicates that the TIMESTAMP type
- should use Oracle's ``TIMESTAMP WITH LOCAL TIME ZONE`` datatype.
+ should use Oracle Database's ``TIMESTAMP WITH LOCAL TIME ZONE`` datatype.
"""
class ROWID(sqltypes.TypeEngine):
- """Oracle ROWID type.
+ """Oracle Database ROWID type.
When used in a cast() or similar, generates ROWID.
:param stream_results: Available on: :class:`_engine.Connection`,
:class:`_sql.Executable`.
- Indicate to the dialect that results should be
- "streamed" and not pre-buffered, if possible. For backends
- such as PostgreSQL, MySQL and MariaDB, this indicates the use of
- a "server side cursor" as opposed to a client side cursor.
- Other backends such as that of Oracle may already use server
- side cursors by default.
+ Indicate to the dialect that results should be "streamed" and not
+ pre-buffered, if possible. For backends such as PostgreSQL, MySQL
+ and MariaDB, this indicates the use of a "server side cursor" as
+ opposed to a client side cursor. Other backends such as that of
+ Oracle Database may already use server side cursors by default.
The usage of
:paramref:`_engine.Connection.execution_options.stream_results` is
``cursor.description`` to set up the keys for the result set,
including the names of columns for the :class:`_engine.Row` object as
well as the dictionary keys when using :attr:`_engine.Row._mapping`.
- On backends that use "name normalization" such as Oracle to correct
- for lower case names being converted to all uppercase, this behavior
- is turned off and the raw UPPERCASE names in cursor.description will
- be present.
+ On backends that use "name normalization" such as Oracle Database to
+ correct for lower case names being converted to all uppercase, this
+ behavior is turned off and the raw UPPERCASE names in
+ cursor.description will be present.
.. versionadded:: 2.1
available if the dialect in use has opted into using the
"use_insertmanyvalues" feature. If they haven't opted into that, then
this attribute is False, unless the dialect in question overrides this
- and provides some other implementation (such as the Oracle dialect).
+ and provides some other implementation (such as the Oracle Database
+ dialects).
"""
return self.insert_returning and self.use_insertmanyvalues
If the dialect in use hasn't opted into that, then this attribute is
False, unless the dialect in question overrides this and provides some
- other implementation (such as the Oracle dialect).
+ other implementation (such as the Oracle Database dialects).
"""
return self.insert_returning and self.use_insertmanyvalues
style of ``setinputsizes()`` on the cursor, using DB-API types
from the bind parameter's ``TypeEngine`` objects.
- This method only called by those dialects which set
- the :attr:`.Dialect.bind_typing` attribute to
- :attr:`.BindTyping.SETINPUTSIZES`. cx_Oracle is the only DBAPI
- that requires setinputsizes(), pyodbc offers it as an option.
+ This method only called by those dialects which set the
+ :attr:`.Dialect.bind_typing` attribute to
+ :attr:`.BindTyping.SETINPUTSIZES`. Python-oracledb and cx_Oracle are
+ the only DBAPIs that requires setinputsizes(); pyodbc offers it as an
+ option.
Prior to SQLAlchemy 2.0, the setinputsizes() approach was also used
for pg8000 and asyncpg, which has been changed to inline rendering
The setinputsizes hook overall is only used for dialects which include
the flag ``use_setinputsizes=True``. Dialects which use this
- include cx_Oracle, pg8000, asyncpg, and pyodbc dialects.
+ include python-oracledb, cx_Oracle, pg8000, asyncpg, and pyodbc dialects.
.. note::
"""Use the pep-249 setinputsizes method.
This is only implemented for DBAPIs that support this method and for which
- the SQLAlchemy dialect has the appropriate infrastructure for that
- dialect set up. Current dialects include cx_Oracle as well as
+ the SQLAlchemy dialect has the appropriate infrastructure for that dialect
+ set up. Current dialects include python-oracledb, cx_Oracle as well as
optional support for SQL Server using pyodbc.
When using setinputsizes, dialects also have a means of only using the
the statement multiple times for a series of batches when large numbers
of rows are given.
- The parameter is False for the default dialect, and is set to
- True for SQLAlchemy internal dialects SQLite, MySQL/MariaDB, PostgreSQL,
- SQL Server. It remains at False for Oracle, which provides native
- "executemany with RETURNING" support and also does not support
- ``supports_multivalues_insert``. For MySQL/MariaDB, those MySQL
- dialects that don't support RETURNING will not report
+ The parameter is False for the default dialect, and is set to True for
+ SQLAlchemy internal dialects SQLite, MySQL/MariaDB, PostgreSQL, SQL Server.
+ It remains at False for Oracle Database, which provides native "executemany
+ with RETURNING" support and also does not support
+ ``supports_multivalues_insert``. For MySQL/MariaDB, those MySQL dialects
+ that don't support RETURNING will not report
``insert_executemany_returning`` as True.
.. versionadded:: 2.0
established on a :class:`.Table` object which will be passed as
"reflection options" when using :paramref:`.Table.autoload_with`.
- Current example is "oracle_resolve_synonyms" in the Oracle dialect.
+ Current example is "oracle_resolve_synonyms" in the Oracle Database
+ dialects.
"""
r"""Return a list of temporary table names for the current bind.
This method is unsupported by most dialects; currently
- only Oracle, PostgreSQL and SQLite implements it.
+ only Oracle Database, PostgreSQL and SQLite implements it.
:param \**kw: Additional keyword argument to pass to the dialect
specific implementation. See the documentation of the dialect
given name was created.
This currently includes some options that apply to MySQL and Oracle
- tables.
+ Database tables.
:param table_name: string name of the table. For special quoting,
use :class:`.quoted_name`.
@compiles(coalesce, 'oracle')
def compile(element, compiler, **kw):
if len(element.clauses) > 2:
- raise TypeError("coalesce only supports two arguments on Oracle")
+ raise TypeError("coalesce only supports two arguments on Oracle Database")
return "nvl(%s)" % compiler.process(element.clauses, **kw)
* :class:`.ExecutableDDLElement` - The root of all DDL expressions,
)
statement._label_style = self.label_style
- # Oracle however does not allow FOR UPDATE on the subquery,
- # and the Oracle dialect ignores it, plus for PostgreSQL, MySQL
+ # Oracle Database however does not allow FOR UPDATE on the subquery,
+ # and the Oracle Database dialects ignore it, plus for PostgreSQL, MySQL
# we expect that all elements of the row are locked, so also put it
# on the outside (except in the case of PG when OF is used)
if (
:param quote:
True if this parameter name requires quoting and is not
currently known as a SQLAlchemy reserved word; this currently
- only applies to the Oracle backend, where bound names must
+ only applies to the Oracle Database backends, where bound names must
sometimes be quoted.
:param isoutparam:
if True, the parameter should be treated like a stored procedure
- "OUT" parameter. This applies to backends such as Oracle which
+ "OUT" parameter. This applies to backends such as Oracle Database which
support OUT parameters.
:param expanding:
"""Called when a SELECT statement has no froms, and no FROM clause is
to be appended.
- Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output.
+ Gives Oracle Database a chance to tack on a ``FROM DUAL`` to the string output.
"""
return ""
``rank()``, ``dense_rank()``, etc.
It's supported only by certain database backends, such as PostgreSQL,
- Oracle and MS SQL Server.
+ Oracle Database and MS SQL Server.
The :class:`.WithinGroup` construct extracts its type from the
method :meth:`.FunctionElement.within_group_type`. If this returns
A :class:`.quoted_name` object with ``quote=True`` is also
prevented from being modified in the case of a so-called
"name normalize" option. Certain database backends, such as
- Oracle, Firebird, and DB2 "normalize" case-insensitive names
+ Oracle Database, Firebird, and DB2 "normalize" case-insensitive names
as uppercase. The SQLAlchemy dialects for these backends
convert from SQLAlchemy's lower-case-means-insensitive convention
to the upper-case-means-insensitive conventions of those backends.
from sqlalchemy import inspect
from sqlalchemy.sql import quoted_name
- engine = create_engine("oracle+cx_oracle://some_dsn")
+ engine = create_engine("oracle+oracledb://some_dsn")
print(inspect(engine).has_table(quoted_name("some_table", True)))
- The above logic will run the "has table" logic against the Oracle backend,
- passing the name exactly as ``"some_table"`` without converting to
+ The above logic will run the "has table" logic against the Oracle Database
+ backend, passing the name exactly as ``"some_table"`` without converting to
upper case.
.. versionchanged:: 1.2 The :class:`.quoted_name` construct is now
:class:`_mysql.match` - MySQL specific construct with
additional features.
- * Oracle - renders ``CONTAINS(x, y)``
+ * Oracle Database - renders ``CONTAINS(x, y)``
* other backends may provide special implementations.
* Backends without any special implementation will emit
the operator as "MATCH". This is compatible with SQLite, for
Examples include:
* PostgreSQL - renders ``x ~ y`` or ``x !~ y`` when negated.
- * Oracle - renders ``REGEXP_LIKE(x, y)``
+ * Oracle Database - renders ``REGEXP_LIKE(x, y)``
* SQLite - uses SQLite's ``REGEXP`` placeholder operator and calls into
the Python ``re.match()`` builtin.
* other backends may provide special implementations.
the operator as "REGEXP" or "NOT REGEXP". This is compatible with
SQLite and MySQL, for example.
- Regular expression support is currently implemented for Oracle,
+ Regular expression support is currently implemented for Oracle Database,
PostgreSQL, MySQL and MariaDB. Partial support is available for
SQLite. Support among third-party dialects may vary.
**not backend agnostic**.
Regular expression replacement support is currently implemented for
- Oracle, PostgreSQL, MySQL 8 or greater and MariaDB. Support among
- third-party dialects may vary.
+ Oracle Database, PostgreSQL, MySQL 8 or greater and MariaDB. Support
+ among third-party dialects may vary.
:param pattern: The regular expression pattern string or column
clause.
unless they are a reserved word. Names with any number of upper
case characters will be quoted and sent exactly. Note that this
behavior applies even for databases which standardize upper
- case names as case insensitive such as Oracle.
+ case names as case insensitive such as Oracle Database.
The name field may be omitted at construction time and applied
later, at any time before the Column is associated with a
will imply that database-specific keywords such as PostgreSQL
``SERIAL``, MySQL ``AUTO_INCREMENT``, or ``IDENTITY`` on SQL Server
should also be rendered. Not every database backend has an
- "implied" default generator available; for example the Oracle
- backend always needs an explicit construct such as
+ "implied" default generator available; for example the Oracle Database
+ backends alway needs an explicit construct such as
:class:`.Identity` to be included with a :class:`.Column` in order
for the DDL rendered to include auto-generating constructs to also
be produced in the database.
is not included as this is unnecessary and not recommended
by the database vendor. See the section
:ref:`sqlite_autoincrement` for more background.
- * Oracle - The Oracle dialect has no default "autoincrement"
+ * Oracle Database - The Oracle Database dialects have no default "autoincrement"
feature available at this time, instead the :class:`.Identity`
construct is recommended to achieve this (the :class:`.Sequence`
construct may also be used).
(see
`https://www.python.org/dev/peps/pep-0249/#lastrowid
<https://www.python.org/dev/peps/pep-0249/#lastrowid>`_)
- * PostgreSQL, SQL Server, Oracle - use RETURNING or an equivalent
+ * PostgreSQL, SQL Server, Oracle Database - use RETURNING or an equivalent
construct when rendering an INSERT statement, and then retrieving
the newly generated primary key values after execution
- * PostgreSQL, Oracle for :class:`_schema.Table` objects that
+ * PostgreSQL, Oracle Database for :class:`_schema.Table` objects that
set :paramref:`_schema.Table.implicit_returning` to False -
for a :class:`.Sequence` only, the :class:`.Sequence` is invoked
explicitly before the INSERT statement takes place so that the
@util.deprecated_params(
order=(
"2.1",
- "This parameter is supported only by Oracle, "
+ "This parameter is supported only by Oracle Database, "
"use ``oracle_order`` instead.",
)
)
:param cache: optional integer value; number of future values in the
sequence which are calculated in advance. Renders the CACHE keyword
- understood by Oracle and PostgreSQL.
+ understood by Oracle Database and PostgreSQL.
:param order: optional boolean value; if ``True``, renders the
- ORDER keyword, understood by Oracle, indicating the sequence is
+ ORDER keyword, understood by Oracle Database, indicating the sequence is
definitively ordered. May be necessary to provide deterministic
ordering using Oracle RAC.
@util.deprecated_params(
order=(
"2.1",
- "This parameter is supported only by Oracle, "
+ "This parameter is supported only by Oracle Database, "
"use ``oracle_order`` instead.",
),
on_null=(
"2.1",
- "This parameter is supported only by Oracle, "
+ "This parameter is supported only by Oracle Database, "
"use ``oracle_on_null`` instead.",
),
)
:param on_null:
Set to ``True`` to specify ON NULL in conjunction with a
``always=False`` identity column. This option is only supported on
- some backends, like Oracle.
+ some backends, like Oracle Database.
:param start: the starting index of the sequence.
:param increment: the increment value of the sequence.
:meth:`_expression.Select.prefix_with` - generic SELECT prefixing
which also can suit some database-specific HINT syntaxes such as
- MySQL or Oracle optimizer hints
+ MySQL or Oracle Database optimizer hints
"""
return self._with_hint(None, text, dialect_name)
**specific to a single table** to a statement, in a location that
is **dialect-specific**. To add generic optimizer hints to the
**beginning** of a statement ahead of the SELECT keyword such as
- for MySQL or Oracle, use the :meth:`_expression.Select.prefix_with`
+ for MySQL or Oracle Database, use the :meth:`_expression.Select.prefix_with`
method. To add optimizer hints to the **end** of a statement such
as for PostgreSQL, use the
:meth:`_expression.Select.with_statement_hint` method.
``selectable`` argument. The dialect implementation
typically uses Python string substitution syntax
with the token ``%(name)s`` to render the name of
- the table or alias. E.g. when using Oracle, the
+ the table or alias. E.g. when using Oracle Database, the
following::
select(mytable).\
The ``dialect_name`` option will limit the rendering of a particular
hint to a particular backend. Such as, to add hints for both Oracle
- and Sybase simultaneously::
+ Database and Sybase simultaneously::
select(mytable).\
with_hint(mytable, "index(%(name)s ix_mytable)", 'oracle').\
:meth:`_expression.Select.prefix_with` - generic SELECT prefixing
which also can suit some database-specific HINT syntaxes such as
- MySQL or Oracle optimizer hints
+ MySQL or Oracle Database optimizer hints
"""
A :class:`_sql.TableValuedColumn` is a :class:`_sql.ColumnElement` that
represents a complete row in a table. Support for this construct is
backend dependent, and is supported in various forms by backends
- such as PostgreSQL, Oracle and SQL Server.
+ such as PostgreSQL, Oracle Database and SQL Server.
E.g.:
Represents an alias, as typically applied to any table or
sub-select within a SQL statement using the ``AS`` keyword (or
- without the keyword on certain databases such as Oracle).
+ without the keyword on certain databases such as Oracle Database).
This object is constructed from the :func:`_expression.alias` module
level function as well as the :meth:`_expression.FromClause.alias`
stmt = select(table).with_for_update(nowait=True)
- On a database like PostgreSQL or Oracle, the above would render a
- statement like::
+ On a database like PostgreSQL or Oracle Database, the above would
+ render a statement like::
SELECT table.a, table.b FROM table FOR UPDATE NOWAIT
variants.
:param nowait: boolean; will render ``FOR UPDATE NOWAIT`` on Oracle
- and PostgreSQL dialects.
+ Database and PostgreSQL dialects.
:param read: boolean; will render ``LOCK IN SHARE MODE`` on MySQL,
``FOR SHARE`` on PostgreSQL. On PostgreSQL, when combined with
:param of: SQL expression or list of SQL expression elements,
(typically :class:`_schema.Column` objects or a compatible expression,
for some backends may also be a table expression) which will render
- into a ``FOR UPDATE OF`` clause; supported by PostgreSQL, Oracle, some
- MySQL versions and possibly others. May render as a table or as a
- column depending on backend.
+ into a ``FOR UPDATE OF`` clause; supported by PostgreSQL, Oracle
+ Database, some MySQL versions and possibly others. May render as a
+ table or as a column depending on backend.
- :param skip_locked: boolean, will render ``FOR UPDATE SKIP LOCKED``
- on Oracle and PostgreSQL dialects or ``FOR SHARE SKIP LOCKED`` if
+ :param skip_locked: boolean, will render ``FOR UPDATE SKIP LOCKED`` on
+ Oracle Databae and PostgreSQL dialects or ``FOR SHARE SKIP LOCKED`` if
``read=True`` is also specified.
:param key_share: boolean, will render ``FOR NO KEY UPDATE``,
"""Return a new selectable with the given FETCH FIRST criterion
applied.
- This is a numeric value which usually renders as
- ``FETCH {FIRST | NEXT} [ count ] {ROW | ROWS} {ONLY | WITH TIES}``
- expression in the resulting select. This functionality is
- is currently implemented for Oracle, PostgreSQL, MSSQL.
+ This is a numeric value which usually renders as ``FETCH {FIRST | NEXT}
+ [ count ] {ROW | ROWS} {ONLY | WITH TIES}`` expression in the resulting
+ select. This functionality is is currently implemented for Oracle
+ Database, PostgreSQL, MSSQL.
Use :meth:`_sql.GenerativeSelect.offset` to specify the offset.
The :class:`.Unicode` type is a :class:`.String` subclass that assumes
input and output strings that may contain non-ASCII characters, and for
some backends implies an underlying column type that is explicitly
- supporting of non-ASCII data, such as ``NVARCHAR`` on Oracle and SQL
- Server. This will impact the output of ``CREATE TABLE`` statements and
+ supporting of non-ASCII data, such as ``NVARCHAR`` on Oracle Database and
+ SQL Server. This will impact the output of ``CREATE TABLE`` statements and
``CAST`` functions at the dialect level.
The character encoding used by the :class:`.Unicode` type that is used to
:meth:`.DialectEvents.do_setinputsizes`
-
"""
__visit_name__ = "unicode"
indicates a number of digits for the generic
:class:`_sqltypes.Float` datatype.
- .. note:: For the Oracle backend, the
+ .. note:: For the Oracle Database backend, the
:paramref:`_sqltypes.Float.precision` parameter is not accepted
- when rendering DDL, as Oracle does not support float precision
+ when rendering DDL, as Oracle Database does not support float precision
specified as a number of decimal places. Instead, use the
- Oracle-specific :class:`_oracle.FLOAT` datatype and specify the
+ Oracle Database-specific :class:`_oracle.FLOAT` datatype and specify the
:paramref:`_oracle.FLOAT.binary_precision` parameter. This is new
in version 2.0 of SQLAlchemy.
To create a database agnostic :class:`_types.Float` that
- separately specifies binary precision for Oracle, use
+ separately specifies binary precision for Oracle Database, use
:meth:`_types.TypeEngine.with_variant` as follows::
from sqlalchemy import Column
to make use of the :class:`_types.TIMESTAMP` datatype directly when
using this flag, as some databases include separate generic
date/time-holding types distinct from the timezone-capable
- TIMESTAMP datatype, such as Oracle.
+ TIMESTAMP datatype, such as Oracle Database.
"""
class Interval(Emulated, _AbstractInterval, TypeDecorator[dt.timedelta]):
"""A type for ``datetime.timedelta()`` objects.
- The Interval type deals with ``datetime.timedelta`` objects. In
- PostgreSQL and Oracle, the native ``INTERVAL`` type is used; for others,
- the value is stored as a date which is relative to the "epoch"
- (Jan. 1, 1970).
+ The Interval type deals with ``datetime.timedelta`` objects. In PostgreSQL
+ and Oracle Database, the native ``INTERVAL`` type is used; for others, the
+ value is stored as a date which is relative to the "epoch" (Jan. 1, 1970).
Note that the ``Interval`` type does not currently provide date arithmetic
operations on platforms which do not support interval types natively. Such
:param native: when True, use the actual
INTERVAL type provided by the database, if
- supported (currently PostgreSQL, Oracle).
+ supported (currently PostgreSQL, Oracle Database).
Otherwise, represent the interval data as
an epoch value regardless.
:param second_precision: For native interval types
which support a "fractional seconds precision" parameter,
- i.e. Oracle and PostgreSQL
+ i.e. Oracle Database and PostgreSQL
:param day_precision: for native interval types which
- support a "day precision" parameter, i.e. Oracle.
+ support a "day precision" parameter, i.e. Oracle Database.
"""
super().__init__()
class TIMESTAMP(DateTime):
"""The SQL TIMESTAMP type.
- :class:`_types.TIMESTAMP` datatypes have support for timezone
- storage on some backends, such as PostgreSQL and Oracle. Use the
+ :class:`_types.TIMESTAMP` datatypes have support for timezone storage on
+ some backends, such as PostgreSQL and Oracle Database. Use the
:paramref:`~types.TIMESTAMP.timezone` argument in order to enable
"TIMESTAMP WITH TIMEZONE" for these backends.
class CLOB(Text):
"""The CLOB type.
- This type is found in Oracle and Informix.
+ This type is found in Oracle Database and Informix.
"""
__visit_name__ = "CLOB"
-"""Drop Oracle, SQL Server databases that are left over from a
+"""Drop Oracle Database, SQL Server databases that are left over from a
multiprocessing test run.
Currently the cx_Oracle driver seems to sometimes not release a