mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-11-22 18:09:41 +01:00
'Adding indexes for all foreign keys' docs
This commit is contained in:
parent
1e917efe31
commit
d82b000e3d
2 changed files with 20 additions and 0 deletions
|
|
@ -310,6 +310,15 @@ If you omit the other table and other column references ``sqlite-utils`` will at
|
||||||
|
|
||||||
See :ref:`python_api_add_foreign_key` in the Python API documentation for further details, including how the automatic table guessing mechanism works.
|
See :ref:`python_api_add_foreign_key` in the Python API documentation for further details, including how the automatic table guessing mechanism works.
|
||||||
|
|
||||||
|
.. _cli_index_foreign_keys:
|
||||||
|
|
||||||
|
Adding indexes for all foreign keys
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
If you want to ensure that every foreign key column in your database has a corresponding index, you can do so like this::
|
||||||
|
|
||||||
|
$ sqlite-utils index-foreign-keys books.db
|
||||||
|
|
||||||
.. _cli_defaults_not_null:
|
.. _cli_defaults_not_null:
|
||||||
|
|
||||||
Setting defaults and not null constraints
|
Setting defaults and not null constraints
|
||||||
|
|
|
||||||
|
|
@ -419,6 +419,17 @@ Here's an example adding two foreign keys at once:
|
||||||
("dogs", "home_town_id", "towns", "id")
|
("dogs", "home_town_id", "towns", "id")
|
||||||
])
|
])
|
||||||
|
|
||||||
|
.. _python_api_index_foreign_keys:
|
||||||
|
|
||||||
|
Adding indexes for all foreign keys
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
If you want to ensure that every foreign key column in your database has a corresponding index, you can do so like this:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
db.index_foreign_keys()
|
||||||
|
|
||||||
.. _python_api_hash:
|
.. _python_api_hash:
|
||||||
|
|
||||||
Setting an ID based on the hash of the row contents
|
Setting an ID based on the hash of the row contents
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue