Can I create an index on a CREATE TABLE
statement?
I.e. can I define indexes for a table when I create the table? I mean create the index on the create stamement sql command
Yes, it can be defined in the CREATE TABLE
, the convention is to put these definitions at the end of the list.
CREATE TABLE `example`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`index_col` VARCHAR(20),
PRIMARY KEY (`id`),
INDEX `index_name` (`index_col`)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With