databases.txt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. .. _ref-databases:
  2. ===============================
  3. Notes about supported databases
  4. ===============================
  5. Django attempts to support as many features as possible on all database
  6. backends. However, not all database backends are alike, and we've had to make
  7. design decisions on which features to support and which assumptions we can make
  8. safely.
  9. This file describes some of the features that might be relevant to Django
  10. usage. Of course, it is not intended as a replacement for server-specific
  11. documentation or reference manuals.
  12. .. _postgresql-notes:
  13. PostgreSQL notes
  14. ================
  15. PostgreSQL 8.2 to 8.2.4
  16. -----------------------
  17. The implementation of the population statistics aggregates ``STDDEV_POP`` and
  18. ``VAR_POP`` that shipped with PostgreSQL 8.2 to 8.2.4 are `known to be
  19. faulty`_. Users of these releases of PostgreSQL are advised to upgrade to
  20. `Release 8.2.5`_ or later. Django will raise a ``NotImplementedError`` if you
  21. attempt to use the ``StdDev(sample=False)`` or ``Variance(sample=False)``
  22. aggregate with a database backend that falls within the affected release range.
  23. .. _known to be faulty: http://archives.postgresql.org/pgsql-bugs/2007-07/msg00046.php
  24. .. _Release 8.2.5: http://developer.postgresql.org/pgdocs/postgres/release-8-2-5.html
  25. Transaction handling
  26. ---------------------
  27. :ref:`By default <topics-db-transactions>`, Django starts a transaction when a
  28. database connection is first used and commits the result at the end of the
  29. request/response handling. The PostgreSQL backends normally operate the same
  30. as any other Django backend in this respect.
  31. Autocommit mode
  32. ~~~~~~~~~~~~~~~
  33. .. versionadded:: 1.1
  34. If your application is particularly read-heavy and doesn't make many database
  35. writes, the overhead of a constantly open transaction can sometimes be
  36. noticeable. For those situations, if you're using the ``postgresql_psycopg2``
  37. backend, you can configure Django to use *"autocommit"* behavior for the
  38. connection, meaning that each database operation will normally be in its own
  39. transaction, rather than having the transaction extend over multiple
  40. operations. In this case, you can still manually start a transaction if you're
  41. doing something that requires consistency across multiple database operations.
  42. The autocommit behavior is enabled by setting the ``autocommit`` key in the
  43. :setting:`DATABASE_OPTIONS` setting::
  44. DATABASE_OPTIONS = {
  45. "autocommit": True,
  46. }
  47. In this configuration, Django still ensures that :ref:`delete()
  48. <topics-db-queries-delete>` and :ref:`update() <topics-db-queries-update>`
  49. queries run inside a single transaction, so that either all the affected
  50. objects are changed or none of them are.
  51. .. admonition:: This is database-level autocommit
  52. This functionality is not the same as the
  53. :ref:`topics-db-transactions-autocommit` decorator. That decorator is a
  54. Django-level implementation that commits automatically after data changing
  55. operations. The feature enabled using the :setting:`DATABASE_OPTIONS`
  56. settings provides autocommit behavior at the database adapter level. It
  57. commits after *every* operation.
  58. If you are using this feature and performing an operation akin to delete or
  59. updating that requires multiple operations, you are strongly recommended to
  60. wrap you operations in manual transaction handling to ensure data consistency.
  61. You should also audit your existing code for any instances of this behavior
  62. before enabling this feature. It's faster, but it provides less automatic
  63. protection for multi-call operations.
  64. .. _mysql-notes:
  65. MySQL notes
  66. ===========
  67. Django expects the database to support transactions, referential integrity,
  68. and Unicode (UTF-8 encoding). Fortunately, MySQL_ has all these
  69. features available as far back as 3.23. While it may be possible to use
  70. 3.23 or 4.0, you'll probably have less trouble if you use 4.1 or 5.0.
  71. MySQL 4.1
  72. ---------
  73. `MySQL 4.1`_ has greatly improved support for character sets. It is possible to
  74. set different default character sets on the database, table, and column.
  75. Previous versions have only a server-wide character set setting. It's also the
  76. first version where the character set can be changed on the fly. 4.1 also has
  77. support for views, but Django currently doesn't use views.
  78. MySQL 5.0
  79. ---------
  80. `MySQL 5.0`_ adds the ``information_schema`` database, which contains detailed
  81. data on all database schema. Django's ``inspectdb`` feature uses this
  82. ``information_schema`` if it's available. 5.0 also has support for stored
  83. procedures, but Django currently doesn't use stored procedures.
  84. .. _MySQL: http://www.mysql.com/
  85. .. _MySQL 4.1: http://dev.mysql.com/doc/refman/4.1/en/index.html
  86. .. _MySQL 5.0: http://dev.mysql.com/doc/refman/5.0/en/index.html
  87. Storage engines
  88. ---------------
  89. MySQL has several `storage engines`_ (previously called table types). You can
  90. change the default storage engine in the server configuration.
  91. The default engine is MyISAM_ [#]_. The main drawback of MyISAM is that it
  92. doesn't currently support transactions or foreign keys. On the plus side, it's
  93. currently the only engine that supports full-text indexing and searching.
  94. The InnoDB_ engine is fully transactional and supports foreign key references.
  95. The BDB_ engine, like InnoDB, is also fully transactional and supports foreign
  96. key references. However, its use seems to be deprecated.
  97. `Other storage engines`_, including SolidDB_ and Falcon_, are on the horizon.
  98. For now, InnoDB is probably your best choice.
  99. .. _storage engines: http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html
  100. .. _MyISAM: http://dev.mysql.com/doc/refman/5.0/en/myisam-storage-engine.html
  101. .. _BDB: http://dev.mysql.com/doc/refman/5.0/en/bdb-storage-engine.html
  102. .. _InnoDB: http://dev.mysql.com/doc/refman/5.0/en/innodb.html
  103. .. _Other storage engines: http://dev.mysql.com/doc/refman/5.1/en/storage-engines-other.html
  104. .. _SolidDB: http://forge.mysql.com/projects/project.php?id=139
  105. .. _Falcon: http://dev.mysql.com/doc/falcon/en/index.html
  106. .. [#] Unless this was changed by the packager of your MySQL package. We've
  107. had reports that the Windows Community Server installer sets up InnoDB as
  108. the default storage engine, for example.
  109. MySQLdb
  110. -------
  111. `MySQLdb`_ is the Python interface to MySQL. Version 1.2.1p2 or later is
  112. required for full MySQL support in Django.
  113. .. note::
  114. If you see ``ImportError: cannot import name ImmutableSet`` when trying to
  115. use Django, your MySQLdb installation may contain an outdated ``sets.py``
  116. file that conflicts with the built-in module of the same name from Python
  117. 2.4 and later. To fix this, verify that you have installed MySQLdb version
  118. 1.2.1p2 or newer, then delete the ``sets.py`` file in the MySQLdb
  119. directory that was left by an earlier version.
  120. .. _MySQLdb: http://sourceforge.net/projects/mysql-python
  121. Creating your database
  122. ----------------------
  123. You can `create your database`_ using the command-line tools and this SQL::
  124. CREATE DATABASE <dbname> CHARACTER SET utf8;
  125. This ensures all tables and columns will use UTF-8 by default.
  126. .. _create your database: http://dev.mysql.com/doc/refman/5.0/en/create-database.html
  127. .. _mysql-collation:
  128. Collation settings
  129. ~~~~~~~~~~~~~~~~~~
  130. The collation setting for a column controls the order in which data is sorted
  131. as well as what strings compare as equal. It can be set on a database-wide
  132. level and also per-table and per-column. This is `documented thoroughly`_ in
  133. the MySQL documentation. In all cases, you set the collation by directly
  134. manipulating the database tables; Django doesn't provide a way to set this on
  135. the model definition.
  136. .. _documented thoroughly: http://dev.mysql.com/doc/refman/5.0/en/charset.html
  137. By default, with a UTF-8 database, MySQL will use the
  138. ``utf8_general_ci_swedish`` collation. This results in all string equality
  139. comparisons being done in a *case-insensitive* manner. That is, ``"Fred"`` and
  140. ``"freD"`` are considered equal at the database level. If you have a unique
  141. constraint on a field, it would be illegal to try to insert both ``"aa"`` and
  142. ``"AA"`` into the same column, since they compare as equal (and, hence,
  143. non-unique) with the default collation.
  144. In many cases, this default will not be a problem. However, if you really want
  145. case-sensitive comparisons on a particular column or table, you would change
  146. the column or table to use the ``utf8_bin`` collation. The main thing to be
  147. aware of in this case is that if you are using MySQLdb 1.2.2, the database backend in Django will then return
  148. bytestrings (instead of unicode strings) for any character fields it returns
  149. receive from the database. This is a strong variation from Django's normal
  150. practice of *always* returning unicode strings. It is up to you, the
  151. developer, to handle the fact that you will receive bytestrings if you
  152. configure your table(s) to use ``utf8_bin`` collation. Django itself should work
  153. smoothly with such columns, but if your code must be prepared to call
  154. ``django.utils.encoding.smart_unicode()`` at times if it really wants to work
  155. with consistent data -- Django will not do this for you (the database backend
  156. layer and the model population layer are separated internally so the database
  157. layer doesn't know it needs to make this conversion in this one particular
  158. case).
  159. If you're using MySQLdb 1.2.1p2, Django's standard
  160. :class:`~django.db.models.CharField` class will return unicode strings even
  161. with ``utf8_bin`` collation. However, :class:`~django.db.models.TextField`
  162. fields will be returned as an ``array.array`` instance (from Python's standard
  163. ``array`` module). There isn't a lot Django can do about that, since, again,
  164. the information needed to make the necessary conversions isn't available when
  165. the data is read in from the database. This problem was `fixed in MySQLdb
  166. 1.2.2`_, so if you want to use :class:`~django.db.models.TextField` with
  167. ``utf8_bin`` collation, upgrading to version 1.2.2 and then dealing with the
  168. bytestrings (which shouldn't be too difficult) is the recommended solution.
  169. Should you decide to use ``utf8_bin`` collation for some of your tables with
  170. MySQLdb 1.2.1p2, you should still use ``utf8_collation_ci_swedish`` (the
  171. default) collation for the :class:`django.contrib.sessions.models.Session`
  172. table (usually called ``django_session`` and the table
  173. :class:`django.contrib.admin.models.LogEntry` table (usually called
  174. ``django_admin_log``). Those are the two standard tables that use
  175. :class:`~django.db.model.TextField` internally.
  176. .. _fixed in MySQLdb 1.2.2: http://sourceforge.net/tracker/index.php?func=detail&aid=1495765&group_id=22307&atid=374932
  177. Connecting to the database
  178. --------------------------
  179. Refer to the :ref:`settings documentation <ref-settings>`.
  180. Connection settings are used in this order:
  181. 1. :setting:`DATABASE_OPTIONS`.
  182. 2. :setting:`DATABASE_NAME`, :setting:`DATABASE_USER`,
  183. :setting:`DATABASE_PASSWORD`, :setting:`DATABASE_HOST`,
  184. :setting:`DATABASE_PORT`
  185. 3. MySQL option files.
  186. In other words, if you set the name of the database in ``DATABASE_OPTIONS``,
  187. this will take precedence over ``DATABASE_NAME``, which would override
  188. anything in a `MySQL option file`_.
  189. Here's a sample configuration which uses a MySQL option file::
  190. # settings.py
  191. DATABASE_ENGINE = "mysql"
  192. DATABASE_OPTIONS = {
  193. 'read_default_file': '/path/to/my.cnf',
  194. }
  195. # my.cnf
  196. [client]
  197. database = DATABASE_NAME
  198. user = DATABASE_USER
  199. password = DATABASE_PASSWORD
  200. default-character-set = utf8
  201. Several other MySQLdb connection options may be useful, such as ``ssl``,
  202. ``use_unicode``, ``init_command``, and ``sql_mode``. Consult the
  203. `MySQLdb documentation`_ for more details.
  204. .. _MySQL option file: http://dev.mysql.com/doc/refman/5.0/en/option-files.html
  205. .. _MySQLdb documentation: http://mysql-python.sourceforge.net/
  206. Creating your tables
  207. --------------------
  208. When Django generates the schema, it doesn't specify a storage engine, so
  209. tables will be created with whatever default storage engine your database
  210. server is configured for. The easiest solution is to set your database server's
  211. default storage engine to the desired engine.
  212. If you're using a hosting service and can't change your server's default
  213. storage engine, you have a couple of options.
  214. * After the tables are created, execute an ``ALTER TABLE`` statement to
  215. convert a table to a new storage engine (such as InnoDB)::
  216. ALTER TABLE <tablename> ENGINE=INNODB;
  217. This can be tedious if you have a lot of tables.
  218. * Another option is to use the ``init_command`` option for MySQLdb prior to
  219. creating your tables::
  220. DATABASE_OPTIONS = {
  221. "init_command": "SET storage_engine=INNODB",
  222. }
  223. This sets the default storage engine upon connecting to the database.
  224. After your tables have been created, you should remove this option.
  225. * Another method for changing the storage engine is described in
  226. AlterModelOnSyncDB_.
  227. .. _AlterModelOnSyncDB: http://code.djangoproject.com/wiki/AlterModelOnSyncDB
  228. Notes on specific fields
  229. ------------------------
  230. Boolean fields
  231. ~~~~~~~~~~~~~~
  232. Since MySQL doesn't have a direct ``BOOLEAN`` column type, Django uses a
  233. ``TINYINT`` column with values of ``1`` and ``0`` to store values for the
  234. :class:`~django.db.models.BooleanField` model field. Refer to the documentation
  235. of that field for more details, but usually this won't be something that will
  236. matter unless you're printing out the field values and are expecting to see
  237. ``True`` and ``False.``.
  238. Character fields
  239. ~~~~~~~~~~~~~~~~
  240. Any fields that are stored with ``VARCHAR`` column types have their
  241. ``max_length`` restricted to 255 characters if you are using ``unique=True``
  242. for the field. This affects :class:`~django.db.models.CharField`,
  243. :class:`~django.db.models.SlugField` and
  244. :class:`~django.db.models.CommaSeparatedIntegerField`.
  245. Furthermore, if you are using a version of MySQL prior to 5.0.3, all of those
  246. column types have a maximum length restriction of 255 characters, regardless
  247. of whether ``unique=True`` is specified or not.
  248. .. _sqlite-notes:
  249. SQLite notes
  250. ============
  251. SQLite_ provides an excellent development alternative for applications that
  252. are predominantly read-only or require a smaller installation footprint. As
  253. with all database servers, though, there are some differences that are
  254. specific to SQLite that you should be aware of.
  255. .. _SQLite: http://www.sqlite.org/
  256. .. _sqlite-string-matching:
  257. String matching for non-ASCII strings
  258. --------------------------------------
  259. SQLite doesn't support case-insensitive matching for non-ASCII strings. Some
  260. possible workarounds for this are `documented at sqlite.org`_, but they are
  261. not utilised by the default SQLite backend in Django. Therefore, if you are
  262. using the ``iexact`` lookup type in your queryset filters, be aware that it
  263. will not work as expected for non-ASCII strings.
  264. .. _documented at sqlite.org: http://www.sqlite.org/faq.html#q18
  265. Versions prior to 3.3.6
  266. ------------------------
  267. Versions of SQLite 3.3.5 and older `contain a bug`_ when handling ``ORDER BY``
  268. parameters. This can cause problems when you use the ``select`` parameter for
  269. the ``extra()`` QuerySet method. The bug can be identified by the error message
  270. ``OperationalError: ORDER BY terms must not be non-integer constants``. The
  271. problem can be solved updating SQLite to version 3.3.6 or newer, possibly also
  272. updating the ``pysqlite2`` Python module in the process.
  273. .. _contain a bug: http://www.sqlite.org/cvstrac/tktview?tn=1768
  274. This has a very low impact because 3.3.6 was released in April 2006, so most
  275. current binary distributions for different platforms include newer version of
  276. SQLite usable from Python through either the ``pysqlite2`` or the ``sqlite3``
  277. modules.
  278. However, in the case of Windows, the official binary distribution of the stable
  279. release of Python 2.5 (2.5.2, as of this writing) includes SQLite 3.3.4, so the bug can
  280. make itself evident in that platform. There are (as of Django 1.0) even three
  281. tests in the Django test suite that will fail when run under this setup. As
  282. described above, this can be solved by downloading and installing a newer
  283. version of ``pysqlite2`` (``pysqlite-2.x.x.win32-py2.5.exe``) that includes and
  284. uses a newer version of SQLite. Python 2.6 ships with a newer version of
  285. SQLite and is not affected by this issue.
  286. If you are in such platform and find yourself in the need to update
  287. ``pysqlite``/SQLite, you will also need to manually modify the
  288. ``django/db/backends/sqlite3/base.py`` file in the Django source tree so it
  289. attempts to import ``pysqlite2`` before than ``sqlite3`` and so it can take
  290. advantage of the new ``pysqlite2``/SQLite versions.
  291. Version 3.5.9
  292. -------------
  293. The Ubuntu "Intrepid Ibex" SQLite 3.5.9-3 package contains a bug that causes
  294. problems with the evaluation of query expressions. If you are using Ubuntu
  295. "Intrepid Ibex", you will need to find an alternate source for SQLite
  296. packages, or install SQLite from source.
  297. At one time, Debian Lenny shipped with the same malfunctioning SQLite 3.5.9-3
  298. package. However the Debian project has subsequently issued updated versions
  299. of the SQLite package that correct these bugs. If you find you are getting
  300. unexpected results under Debian, ensure you have updated your SQLite package
  301. to 3.5.9-5 or later.
  302. The problem does not appear to exist with other versions of SQLite packaged
  303. with other operating systems.
  304. Version 3.6.2
  305. --------------
  306. SQLite version 3.6.2 (released August 30, 2008) introduced a bug into ``SELECT
  307. DISTINCT`` handling that is triggered by, amongst other things, Django's
  308. ``DateQuerySet`` (returned by the ``dates()`` method on a queryset).
  309. You should avoid using this version of SQLite with Django. Either upgrade to
  310. 3.6.3 (released September 22, 2008) or later, or downgrade to an earlier
  311. version of SQLite.
  312. .. _oracle-notes:
  313. Oracle notes
  314. ============
  315. Django supports `Oracle Database Server`_ versions 9i and
  316. higher. Oracle version 10g or later is required to use Django's
  317. ``regex`` and ``iregex`` query operators. You will also need at least
  318. version 4.3.1 of the `cx_Oracle`_ Python driver.
  319. Note that due to a Unicode-corruption bug in ``cx_Oracle`` 5.0, that
  320. version of the driver should **not** be used with Django;
  321. ``cx_Oracle`` 5.0.1 resolved this issue, so if you'd like to use a
  322. more recent ``cx_Oracle``, use version 5.0.1.
  323. .. _`Oracle Database Server`: http://www.oracle.com/
  324. .. _`cx_Oracle`: http://cx-oracle.sourceforge.net/
  325. In order for the ``python manage.py syncdb`` command to work, your Oracle
  326. database user must have privileges to run the following commands:
  327. * CREATE TABLE
  328. * CREATE SEQUENCE
  329. * CREATE PROCEDURE
  330. * CREATE TRIGGER
  331. To run Django's test suite, the user needs these *additional* privileges:
  332. * CREATE USER
  333. * DROP USER
  334. * CREATE TABLESPACE
  335. * DROP TABLESPACE
  336. Connecting to the database
  337. --------------------------
  338. Your Django settings.py file should look something like this for Oracle::
  339. DATABASE_ENGINE = 'oracle'
  340. DATABASE_NAME = 'xe'
  341. DATABASE_USER = 'a_user'
  342. DATABASE_PASSWORD = 'a_password'
  343. DATABASE_HOST = ''
  344. DATABASE_PORT = ''
  345. If you don't use a ``tnsnames.ora`` file or a similar naming method that
  346. recognizes the SID ("xe" in this example), then fill in both
  347. :setting:`DATABASE_HOST` and :setting:`DATABASE_PORT` like so::
  348. DATABASE_ENGINE = 'oracle'
  349. DATABASE_NAME = 'xe'
  350. DATABASE_USER = 'a_user'
  351. DATABASE_PASSWORD = 'a_password'
  352. DATABASE_HOST = 'dbprod01ned.mycompany.com'
  353. DATABASE_PORT = '1540'
  354. You should supply both :setting:`DATABASE_HOST` and :setting:`DATABASE_PORT`, or leave both
  355. as empty strings.
  356. Tablespace options
  357. ------------------
  358. A common paradigm for optimizing performance in Oracle-based systems is the
  359. use of `tablespaces`_ to organize disk layout. The Oracle backend supports
  360. this use case by adding ``db_tablespace`` options to the ``Meta`` and
  361. ``Field`` classes. (When you use a backend that lacks support for tablespaces,
  362. Django ignores these options.)
  363. .. _`tablespaces`: http://en.wikipedia.org/wiki/Tablespace
  364. A tablespace can be specified for the table(s) generated by a model by
  365. supplying the ``db_tablespace`` option inside the model's ``class Meta``.
  366. Additionally, you can pass the ``db_tablespace`` option to a ``Field``
  367. constructor to specify an alternate tablespace for the ``Field``'s column
  368. index. If no index would be created for the column, the ``db_tablespace``
  369. option is ignored::
  370. class TablespaceExample(models.Model):
  371. name = models.CharField(max_length=30, db_index=True, db_tablespace="indexes")
  372. data = models.CharField(max_length=255, db_index=True)
  373. edges = models.ManyToManyField(to="self", db_tablespace="indexes")
  374. class Meta:
  375. db_tablespace = "tables"
  376. In this example, the tables generated by the ``TablespaceExample`` model
  377. (i.e., the model table and the many-to-many table) would be stored in the
  378. ``tables`` tablespace. The index for the name field and the indexes on the
  379. many-to-many table would be stored in the ``indexes`` tablespace. The ``data``
  380. field would also generate an index, but no tablespace for it is specified, so
  381. it would be stored in the model tablespace ``tables`` by default.
  382. .. versionadded:: 1.0
  383. Use the :setting:`DEFAULT_TABLESPACE` and :setting:`DEFAULT_INDEX_TABLESPACE`
  384. settings to specify default values for the db_tablespace options.
  385. These are useful for setting a tablespace for the built-in Django apps and
  386. other applications whose code you cannot control.
  387. Django does not create the tablespaces for you. Please refer to `Oracle's
  388. documentation`_ for details on creating and managing tablespaces.
  389. .. _`Oracle's documentation`: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7003.htm#SQLRF01403
  390. Naming issues
  391. -------------
  392. Oracle imposes a name length limit of 30 characters. To accommodate this, the
  393. backend truncates database identifiers to fit, replacing the final four
  394. characters of the truncated name with a repeatable MD5 hash value.
  395. NULL and empty strings
  396. ----------------------
  397. Django generally prefers to use the empty string ('') rather than
  398. NULL, but Oracle treats both identically. To get around this, the
  399. Oracle backend coerces the ``null=True`` option on fields that have
  400. the empty string as a possible value. When fetching from the database,
  401. it is assumed that a NULL value in one of these fields really means
  402. the empty string, and the data is silently converted to reflect this
  403. assumption.
  404. ``TextField`` limitations
  405. -------------------------
  406. The Oracle backend stores ``TextFields`` as ``NCLOB`` columns. Oracle imposes
  407. some limitations on the usage of such LOB columns in general:
  408. * LOB columns may not be used as primary keys.
  409. * LOB columns may not be used in indexes.
  410. * LOB columns may not be used in a ``SELECT DISTINCT`` list. This means that
  411. attempting to use the ``QuerySet.distinct`` method on a model that
  412. includes ``TextField`` columns will result in an error when run against
  413. Oracle. A workaround to this is to keep ``TextField`` columns out of any
  414. models that you foresee performing ``distinct()`` queries on, and to
  415. include the ``TextField`` in a related model instead.