Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #13245: Explained Oracle's behavior w.r.t db_table

and how to prevent table-name truncation

Thanks russellm & timo for discussion, and timo for review.

Backported from master 317040a
  • Loading branch information...
commit 27f3f341369c8e18ea4a360a1f7c01531836b68b 1 parent 9c98205
@shaib shaib authored
Showing with 28 additions and 0 deletions.
  1. +16 −0 docs/ref/databases.txt
  2. +12 −0 docs/ref/models/options.txt
View
16 docs/ref/databases.txt
@@ -762,6 +762,22 @@ Naming issues
Oracle imposes a name length limit of 30 characters. To accommodate this, the
backend truncates database identifiers to fit, replacing the final four
characters of the truncated name with a repeatable MD5 hash value.
+Additionally, the backend turns database identifiers to all-uppercase.
+
+To prevent these transformations (this is usually required only when dealing
+with legacy databases or accessing tables which belong to other users), use
+a quoted name as the value for ``db_table``::
+
+ class LegacyModel(models.Model):
+ class Meta:
+ db_table = '"name_left_in_lowercase"'
+
+ class ForeignModel(models.Model):
+ class Meta:
+ db_table = '"OTHER_USER"."NAME_ONLY_SEEMS_OVER_30"'
+
+Quoted names can also be used with Django's other supported database
+backends; except for Oracle, however, the quotes have no effect.
When running syncdb, an ``ORA-06552`` error may be encountered if
certain Oracle keywords are used as the name of a model field or the
View
12 docs/ref/models/options.txt
@@ -67,6 +67,18 @@ Django quotes column and table names behind the scenes.
the table name via ``db_table``, particularly if you are using the MySQL
backend. See the :ref:`MySQL notes <mysql-notes>` for more details.
+.. admonition:: Table name quoting for Oracle
+
+ In order to to meet the 30-char limitation Oracle has on table names,
+ and match the usual conventions for Oracle databases, Django may shorten
+ table names and turn them all-uppercase. To prevent such transformations,
+ use a quoted name as the value for ``db_table``::
+
+ db_table = '"name_left_in_lowercase"'
+
+ Such quoted names can also be used with Django's other supported database
+ backends; except for Oracle, however, the quotes have no effect. See the
+ :ref:`Oracle notes <oracle-notes>` for more details.
``db_tablespace``
-----------------
Please sign in to comment.
Something went wrong with that request. Please try again.