Changeset 6763
- Timestamp:
- 11/29/07 23:03:32 (9 months ago)
- Files:
-
- django/trunk/docs/databases.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/databases.txt
r6561 r6763 173 173 174 174 175 Oracle Notes175 Oracle notes 176 176 ============ 177 177 178 Django supports `Oracle Database Server`_ versions 9i and higher. Oracle178 Django supports `Oracle Database Server`_ versions 9i and higher. Oracle 179 179 version 10g or later is required to use Django's ``regex`` and ``iregex`` query 180 operators. You will also need the `cx_Oracle`_ driver, version 4.3.1 or newer.180 operators. You will also need the `cx_Oracle`_ driver, version 4.3.1 or newer. 181 181 182 182 .. _`Oracle Database Server`: http://www.oracle.com/ 183 183 .. _`cx_Oracle`: http://cx-oracle.sourceforge.net/ 184 184 185 To run ``python manage.py syncdb``, you'll need to create an Oracle database 186 user with CREATE TABLE, CREATE SEQUENCE, CREATE PROCEDURE, and CREATE TRIGGER 187 privileges. To run Django's test suite, the user also needs 188 CREATE and DROP DATABASE and CREATE and DROP TABLESPACE privileges. 189 190 Connecting to the Database 185 In order for the ``python manage.py syncdb`` command to work, your Oracle 186 database user must have privileges to run the following commands: 187 188 * CREATE TABLE 189 * CREATE SEQUENCE 190 * CREATE PROCEDURE 191 * CREATE TRIGGER 192 193 To run Django's test suite, the user needs these *additional* privileges: 194 195 * CREATE DATABASE 196 * DROP DATABASE 197 * CREATE TABLESPACE 198 * DROP TABLESPACE 199 200 Connecting to the database 191 201 -------------------------- 192 202 … … 214 224 as empty strings. 215 225 216 Tablespace Options226 Tablespace options 217 227 ------------------ 218 228 … … 220 230 use of `tablespaces`_ to organize disk layout. The Oracle backend supports 221 231 this use case by adding ``db_tablespace`` options to the ``Meta`` and 222 ``Field`` classes. (When usinga backend that lacks support for tablespaces,223 these options are ignored.)232 ``Field`` classes. (When you use a backend that lacks support for tablespaces, 233 Django ignores these options.) 224 234 225 235 .. _`tablespaces`: http://en.wikipedia.org/wiki/Tablespace 226 236 227 237 A tablespace can be specified for the table(s) generated by a model by 228 supplying the ``db_tablespace`` option inside the model's `` Meta`` class.229 Additionally, the ``db_tablespace`` option can be passedto a ``Field``238 supplying the ``db_tablespace`` option inside the model's ``class Meta``. 239 Additionally, you can pass the ``db_tablespace`` option to a ``Field`` 230 240 constructor to specify an alternate tablespace for the ``Field``'s column 231 index. If no index would be created for the column, the ``db_tablespace``241 index. If no index would be created for the column, the ``db_tablespace`` 232 242 option is ignored. 233 243 … … 235 245 236 246 class TablespaceExample(models.Model): 237 name = models.CharField(max length=30, db_index=True, db_tablespace="indexes")238 data = models.CharField(max length=255, db_index=True)247 name = models.CharField(max_length=30, db_index=True, db_tablespace="indexes") 248 data = models.CharField(max_length=255, db_index=True) 239 249 edges = models.ManyToManyField(to="self", db_tablespace="indexes") 240 250 … … 244 254 In this example, the tables generated by the ``TablespaceExample`` model 245 255 (i.e., the model table and the many-to-many table) would be stored in the 246 ``tables`` tablespace. The index for the name field and the indexes on the247 many-to-many table would be stored in the ``indexes`` tablespace. The ``data``256 ``tables`` tablespace. The index for the name field and the indexes on the 257 many-to-many table would be stored in the ``indexes`` tablespace. The ``data`` 248 258 field would also generate an index, but no tablespace for it is specified, so 249 259 it would be stored in the model tablespace ``tables`` by default. 250 260 251 Django does not create the tablespaces for you. Please refer to `Oracle's261 Django does not create the tablespaces for you. Please refer to `Oracle's 252 262 documentation`_ for details on creating and managing tablespaces. 253 263 254 264 .. _`Oracle's documentation`: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7003.htm#SQLRF01403 255 265 256 Naming Issues266 Naming issues 257 267 ------------- 258 268 259 Oracle imposes a name length limit of 30 characters. To accommodate this, the269 Oracle imposes a name length limit of 30 characters. To accommodate this, the 260 270 backend truncates database identifiers to fit, replacing the final four 261 271 characters of the truncated name with a repeatable MD5 hash value. 262 272 263 NULL and Empty Strings273 NULL and empty strings 264 274 ---------------------- 265 275 266 276 Django generally prefers to use the empty string ('') rather than NULL, but 267 Oracle treats both identically. To get around this, the Oracle backend277 Oracle treats both identically. To get around this, the Oracle backend 268 278 coerces the ``null=True`` option on fields that permit the empty string as a 269 value. When fetching from the database, it is assumed that a NULL value in279 value. When fetching from the database, it is assumed that a NULL value in 270 280 one of these fields really means the empty string, and the data is silently 271 281 converted to reflect this assumption. 272 282 273 TextField Limitations274 --------------------- 275 276 The Oracle backend stores ``TextFields`` as ``NCLOB`` columns. Oracle imposes283 ``TextField`` limitations 284 ------------------------- 285 286 The Oracle backend stores ``TextFields`` as ``NCLOB`` columns. Oracle imposes 277 287 some limitations on the usage of such LOB columns in general: 278 288 … … 281 291 * LOB columns may not be used in indexes. 282 292 283 * LOB columns may not be used in a ``SELECT DISTINCT`` list. This means that293 * LOB columns may not be used in a ``SELECT DISTINCT`` list. This means that 284 294 attempting to use the ``QuerySet.distinct`` method on a model that 285 295 includes ``TextField`` columns will result in an error when run against 286 Oracle. A workaround to this is to keep ``TextField`` columns out of any287 models that you foresee performing `` .distinct`` queries on, and to296 Oracle. A workaround to this is to keep ``TextField`` columns out of any 297 models that you foresee performing ``distinct()`` queries on, and to 288 298 include the ``TextField`` in a related model instead.
