Django

Code

Changeset 6763

Show
Ignore:
Timestamp:
11/29/07 23:03:32 (9 months ago)
Author:
adrian
Message:

Edited docs/databases.txt Oracle changes from [6432]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/databases.txt

    r6561 r6763  
    173173 
    174174 
    175 Oracle Notes 
     175Oracle notes 
    176176============ 
    177177 
    178 Django supports `Oracle Database Server`_ versions 9i and higher. Oracle 
     178Django supports `Oracle Database Server`_ versions 9i and higher. Oracle 
    179179version 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. 
     180operators. You will also need the `cx_Oracle`_ driver, version 4.3.1 or newer. 
    181181 
    182182.. _`Oracle Database Server`: http://www.oracle.com/ 
    183183.. _`cx_Oracle`: http://cx-oracle.sourceforge.net/ 
    184184 
    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 
     185In order for the ``python manage.py syncdb`` command to work, your Oracle 
     186database user must have privileges to run the following commands: 
     187 
     188        * CREATE TABLE 
     189        * CREATE SEQUENCE 
     190        * CREATE PROCEDURE 
     191        * CREATE TRIGGER 
     192 
     193To 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 
     200Connecting to the database 
    191201-------------------------- 
    192202 
     
    214224as empty strings. 
    215225 
    216 Tablespace Options 
     226Tablespace options 
    217227------------------ 
    218228 
     
    220230use of `tablespaces`_ to organize disk layout. The Oracle backend supports 
    221231this use case by adding ``db_tablespace`` options to the ``Meta`` and 
    222 ``Field`` classes.  (When using a backend that lacks support for tablespaces, 
    223 these options are ignored.) 
     232``Field`` classes.  (When you use a backend that lacks support for tablespaces, 
     233Django ignores these options.) 
    224234 
    225235.. _`tablespaces`: http://en.wikipedia.org/wiki/Tablespace 
    226236 
    227237A 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 passed to a ``Field`` 
     238supplying the ``db_tablespace`` option inside the model's ``class Meta``
     239Additionally, you can pass the ``db_tablespace`` option to a ``Field`` 
    230240constructor to specify an alternate tablespace for the ``Field``'s column 
    231 index. If no index would be created for the column, the ``db_tablespace`` 
     241index. If no index would be created for the column, the ``db_tablespace`` 
    232242option is ignored. 
    233243 
     
    235245 
    236246    class TablespaceExample(models.Model): 
    237         name = models.CharField(maxlength=30, db_index=True, db_tablespace="indexes") 
    238         data = models.CharField(maxlength=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) 
    239249        edges = models.ManyToManyField(to="self", db_tablespace="indexes") 
    240250 
     
    244254In this example, the tables generated by the ``TablespaceExample`` model 
    245255(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 the 
    247 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 
     257many-to-many table would be stored in the ``indexes`` tablespace. The ``data`` 
    248258field would also generate an index, but no tablespace for it is specified, so 
    249259it would be stored in the model tablespace ``tables`` by default. 
    250260 
    251 Django does not create the tablespaces for you. Please refer to `Oracle's 
     261Django does not create the tablespaces for you. Please refer to `Oracle's 
    252262documentation`_ for details on creating and managing tablespaces. 
    253263 
    254264.. _`Oracle's documentation`: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7003.htm#SQLRF01403 
    255265 
    256 Naming Issues 
     266Naming issues 
    257267------------- 
    258268 
    259 Oracle imposes a name length limit of 30 characters. To accommodate this, the 
     269Oracle imposes a name length limit of 30 characters. To accommodate this, the 
    260270backend truncates database identifiers to fit, replacing the final four 
    261271characters of the truncated name with a repeatable MD5 hash value. 
    262272 
    263 NULL and Empty Strings 
     273NULL and empty strings 
    264274---------------------- 
    265275 
    266276Django generally prefers to use the empty string ('') rather than NULL, but 
    267 Oracle treats both identically. To get around this, the Oracle backend 
     277Oracle treats both identically. To get around this, the Oracle backend 
    268278coerces 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 in 
     279value. When fetching from the database, it is assumed that a NULL value in 
    270280one of these fields really means the empty string, and the data is silently 
    271281converted to reflect this assumption. 
    272282 
    273 TextField Limitations 
    274 --------------------- 
    275  
    276 The Oracle backend stores ``TextFields`` as ``NCLOB`` columns. Oracle imposes 
     283``TextField`` limitations 
     284------------------------- 
     285 
     286The Oracle backend stores ``TextFields`` as ``NCLOB`` columns. Oracle imposes 
    277287some limitations on the usage of such LOB columns in general: 
    278288 
     
    281291  * LOB columns may not be used in indexes. 
    282292 
    283   * LOB columns may not be used in a ``SELECT DISTINCT`` list. This means that 
     293  * LOB columns may not be used in a ``SELECT DISTINCT`` list. This means that 
    284294    attempting to use the ``QuerySet.distinct`` method on a model that 
    285295    includes ``TextField`` columns will result in an error when run against 
    286     Oracle. A workaround to this is to keep ``TextField`` columns out of any 
    287     models that you foresee performing ``.distinct`` queries on, and to 
     296    Oracle. A workaround to this is to keep ``TextField`` columns out of any 
     297    models that you foresee performing ``distinct()`` queries on, and to 
    288298    include the ``TextField`` in a related model instead.