diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-11 02:22:36 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-11 02:22:54 -0400 |
| commit | f3fc5840554c1b56f91479d357f81f86faec8a34 (patch) | |
| tree | 9988c322024bec40c9ab5efe5e897ce8f9beb3c0 /lib/sqlalchemy | |
| parent | ca078368ca66a09c63116aa9afaeecdd939b9262 (diff) | |
| download | sqlalchemy-f3fc5840554c1b56f91479d357f81f86faec8a34.tar.gz | |
add more docs to index, even though this seems to be a little redundant
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/schema.py | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 6bd0283ff..062c3c04e 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2350,9 +2350,34 @@ class UniqueConstraint(ColumnCollectionConstraint): class Index(ColumnCollectionMixin, SchemaItem): """A table-level INDEX. - Defines a composite (one or more column) INDEX. For a no-frills, single - column index, adding ``index=True`` to the ``Column`` definition is - a shorthand equivalent for an unnamed, single column :class:`.Index`. + Defines a composite (one or more column) INDEX. + + E.g.:: + + sometable = Table("sometable", metadata, + Column("name", String(50)), + Column("address", String(100)) + ) + + Index("some_index", sometable.c.name) + + For a no-frills, single column index, adding + :class:`.Column` also supports ``index=True``:: + + sometable = Table("sometable", metadata, + Column("name", String(50), index=True) + ) + + For a composite index, multiple columns can be specified:: + + Index("some_index", sometable.c.name, sometable.c.address) + + Functional indexes are supported as well, keeping in mind that at least + one :class:`.Column` must be present:: + + Index("some_index", func.lower(sometable.c.name)) + + .. versionadded:: 0.8 support for functional and expression-based indexes. .. seealso:: @@ -2378,13 +2403,7 @@ class Index(ColumnCollectionMixin, SchemaItem): The name of the index :param \*expressions: - Column expressions to include in the index. The expressions - are normally instances of :class:`.Column`, but may also - be arbitrary SQL expressions which ultmately refer to a - :class:`.Column`. - - .. versionadded:: 0.8 :class:`.Index` supports SQL expressions as - well as plain columns. + Column or SQL expressions. :param unique: Defaults to False: create a unique index. |
