6.6. SQL Index

  • Used to create and retrieve data from the database very quickly

  • Analog to notebook calendar tabs

../../_images/sql-index-notebookcalendar.png

6.6.1. Index Types

  • Column Index

  • Multi Column Index

  • Partial Index

  • Functional Index

  • Binary Index

6.6.2. SQL Syntax

CREATE INDEX astronaut_agency_index
ON astronaut (agency);

6.6.3. If Not Exists

  • IF NOT EXISTS

CREATE INDEX IF NOT EXISTS astronaut_agency_index
ON astronaut (agency);

6.6.4. Unique Index

  • UNIQUE

CREATE UNIQUE INDEX IF NOT EXISTS astronaut_agency_index
ON astronaut (agency);