Skip to content

Instantly share code, notes, and snippets.

@mramirid
Last active November 28, 2023 02:18
Show Gist options
  • Save mramirid/68301dd19a88360bab1d085d21eaf7ca to your computer and use it in GitHub Desktop.
Save mramirid/68301dd19a88360bab1d085d21eaf7ca to your computer and use it in GitHub Desktop.
Creating Indexes During Table Creation

Creating Indexes During Table Creation

We can add an index to a table right when creating that table - like this:

CREATE TABLE <table_name> (
    ... column definitions,
    INDEX <index_name> (<column>)
);

Please note that this is supported when using MySQL but it won't work with PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment