2
CREATE TABLE `blog` (
    `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
    `title` text,
    `content` text,
    `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`),
    KEY `ix_deleted` (`deleted`)
) ENGINE=InnoDB
  AUTO_INCREMENT=1
  DEFAULT CHARSET=utf8
  COMMENT='Blog posts';

I have created table and i want to implement trigger. I want to know what is the purpose of this line of code in this query.

KEY `ix_deleted` (`deleted`)
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
  • 1
    It creates an index (or "key") on the `deleted` column. The index's identifier or name is `ix_deleted`. It's a common convention to prefix an index's name with `ix_` or `idx_`. – Michael Berkowski Jan 29 '15 at 16:14
  • There are some details about this in the [`CREATE TABLE` syntax reference](http://dev.mysql.com/doc/refman/5.1/en/create-table.html) particluarly the `| {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)` line. – Michael Berkowski Jan 29 '15 at 16:15
  • @MichaelBerkowski You should include that as an answer – chridam Jan 29 '15 at 16:16

0 Answers0