{"id":191,"date":"2009-12-27T09:37:26","date_gmt":"2009-12-27T09:37:26","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=191"},"modified":"2023-12-29T01:54:14","modified_gmt":"2023-12-29T08:54:14","slug":"mysql-create-index","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/","title":{"rendered":"MySQL CREATE INDEX"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about the index and how to use the MySQL <code>CREATE INDEX<\/code> statement to add an index to a table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The phone book&nbsp;analogy<\/h2>\n\n\n\n<p>Suppose you have a phone book that contains all the names and phone numbers of people in a city. <\/p>\n\n\n\n<p>Let&#8217;s say you want to find Bob Cat&#8217;s phone number. Knowing that the names are alphabetically ordered, you first look for the page where the last name is <code>Cat<\/code>, then you look for <code>Bob<\/code> and his phone number.<\/p>\n\n\n\n<p>If the names in the phone book were not sorted alphabetically, you would need to go through all the pages, reading every name on it until you find <code>Bob Cat<\/code>. <\/p>\n\n\n\n<p>This is called <strong>sequential searching<\/strong>. You go over all the entries until you find the person with the phone number that you are looking for.<\/p>\n\n\n\n<p>Relating the phone book to the table, if you have the table <code>phonebooks<\/code> and you need to find the phone number of <code>Bob Cat<\/code>, you would perform the following query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\n    phone_number\n<span class=\"hljs-keyword\">FROM<\/span> \n    phonebooks\n<span class=\"hljs-keyword\">WHERE<\/span> \n    first_name = <span class=\"hljs-string\">'Bob'<\/span> <span class=\"hljs-keyword\">AND<\/span> \n    last_name = <span class=\"hljs-string\">'Cat'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It is pretty easy. Although the query is fast, the database has to scan all the rows of the table until it finds the row. If the table has millions of rows, without an index, the data retrieval would take a lot of time to return the result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to Database Indexes<\/h2>\n\n\n\n<p>An index is a data structure such as a B-Tree that improves the speed of data retrieval on a table at the cost of additional writes and storage to maintain it.<\/p>\n\n\n\n<p>The query optimizer may use indexes to quickly locate data without having to scan every row in a table for a given query.<\/p>\n\n\n\n<p>When you <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-create-table\/\">create a table<\/a> with a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-primary-key\/\">primary key<\/a> or<a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-unique-constraint\/\"> unique key<\/a>, MySQL automatically creates a special index named <code>PRIMARY<\/code>. This index is called the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-clustered-index\/\">clustered index<\/a>.<\/p>\n\n\n\n<p>The <code>PRIMARY<\/code> index is special because the index itself is stored together with the data in the same table. The clustered index enforces the order of rows in the table.<\/p>\n\n\n\n<p>Other indexes other than the <code>PRIMARY<\/code> index are called secondary indexes or non-clustered indexes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL CREATE INDEX statement<\/h2>\n\n\n\n<p>Typically, you create indexes for a table at the time of creation. For example, the following statement <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-create-table\/\">creates a new table<\/a> with an index that consists of two columns c2 and c3.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> t(\n   c1 <span class=\"hljs-built_in\">INT<\/span> PRIMARY <span class=\"hljs-keyword\">KEY<\/span>,\n   c2 <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n   c3 <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n   c4 <span class=\"hljs-built_in\">VARCHAR<\/span>(<span class=\"hljs-number\">10<\/span>),\n   <span class=\"hljs-keyword\">INDEX<\/span> (c2,c3) \n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To add an index for a column or a set of columns, you use the <code>CREATE INDEX<\/code> statement as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">INDEX<\/span> index_name \n<span class=\"hljs-keyword\">ON<\/span> table_name (column_list)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To create an index for a column or a list of columns, you specify the index name, the table to which the index belongs, and the column list.<\/p>\n\n\n\n<p>For example, to add a new index for the column c4, you use the following statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">INDEX<\/span> idx_c4 <span class=\"hljs-keyword\">ON<\/span> t(c4);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>By default, MySQL creates the B-Tree index if you don&#8217;t specify the index type. <\/p>\n\n\n\n<p>The following table shows the valid index types based on the <a href=\"https:\/\/www.mysqltutorial.org\/mysql-administration\/mysql-storage-engines\/\">storage engine<\/a> of the table:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th scope=\"col\">Storage Engine<\/th><th scope=\"col\">Allowed Index Types<\/th><\/tr><\/thead><tbody><tr><td>InnoDB<\/td><td>BTREE<\/td><\/tr><tr><td>MyISAM<\/td><td>BTREE<\/td><\/tr><tr><td>MEMORY\/HEAP<\/td><td>HASH,&nbsp;BTREE<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Notice that the <code>CREATE INDEX<\/code> statement above is a simplified version of the <code>CREATE INDEX<\/code> statement introduced by MySQL. We will cover more options in the subsequent tutorials.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL CREATE INDEX example<\/h2>\n\n\n\n<p>The following statement finds employees whose job title is <code>Sales Rep<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \n    employeeNumber, \n    lastName, \n    firstName\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobTitle = <span class=\"hljs-string\">'Sales Rep'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"217\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png\" alt=\"MySQL Index example\" class=\"wp-image-6801\" title=\"MySQL Index example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png 250w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example-200x174.png 200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/figure>\n\n\n\n<p>We have 17 rows indicating that 17 employees whose job title is the Sales Rep.<\/p>\n\n\n\n<p>To see how MySQL internally performed this query, you add the <code>EXPLAIN<\/code>&nbsp;clause at the beginning of the <code>SELECT<\/code> statement as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"692\" height=\"39\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-EXPLAIN-statement.png\" alt=\"MySQL Index EXPLAIN statement\" class=\"wp-image-6799\" title=\"MySQL Index EXPLAIN statement\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-EXPLAIN-statement.png 692w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-EXPLAIN-statement-200x11.png 200w\" sizes=\"auto, (max-width: 692px) 100vw, 692px\" \/><\/figure>\n\n\n\n<p>As you can see, MySQL had to scan the whole table which consists of 23 rows to find the employees with the <code>Sales Rep<\/code> job title.<\/p>\n\n\n\n<p>Now, let&#8217;s create an index for the &nbsp;<code>jobTitle<\/code> column by using the <code>CREATE INDEX<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">INDEX<\/span> jobTitle \n<span class=\"hljs-keyword\">ON<\/span> employees(jobTitle);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Execute the <code>EXPLAIN<\/code> statement again:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">EXPLAIN<\/span> <span class=\"hljs-keyword\">SELECT<\/span> \n    employeeNumber, \n    lastName, \n    firstName\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobTitle = <span class=\"hljs-string\">'Sales Rep'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The output is:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"671\" height=\"38\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-effect.png\" alt=\"\" class=\"wp-image-6800\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-effect.png 671w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-effect-200x11.png 200w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/figure>\n\n\n\n<p>The output shows that MySQL just had to locate 17 rows from the \u00a0<code>jobTitle<\/code> index as indicated in the key column without scanning the whole table.<\/p>\n\n\n\n<p>To list all indexes of a table, you use the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-show-indexes\/\">SHOW INDEXES<\/a><\/code> statement, for example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SHOW<\/span> <span class=\"hljs-keyword\">INDEXES<\/span> <span class=\"hljs-keyword\">FROM<\/span> employees;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"951\" height=\"85\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Create-Index-Example.png\" alt=\"MySQL CREATE INDEX example\" class=\"wp-image-6901\" title=\"MySQL CREATE INDEX example\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Create-Index-Example.png 951w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Create-Index-Example-200x18.png 200w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Create-Index-Example-768x69.png 768w\" sizes=\"auto, (max-width: 951px) 100vw, 951px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A database index enhances retrieval speed but comes with the cost of increased writing overhead.<\/li>\n\n\n\n<li>Use the <code>CREATE INDEX<\/code> statement to create a new index for a table.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful? <\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"191\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/\"\n\t\t\t\tdata-post-title=\"MySQL CREATE INDEX\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"191\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/\"\n\t\t\t\tdata-post-title=\"MySQL CREATE INDEX\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to work with MySQL index and how to take advantages of  MySQL index to speed up the data retrieval.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":6818,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-191","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL CREATE INDEX<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL CREATE INDEX\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-29T08:54:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/\",\"name\":\"MySQL CREATE INDEX\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-Index-example.png\",\"datePublished\":\"2009-12-27T09:37:26+00:00\",\"dateModified\":\"2023-12-29T08:54:14+00:00\",\"description\":\"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-Index-example.png\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/MySQL-Index-example.png\",\"width\":250,\"height\":217,\"caption\":\"MySQL Index example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/mysql-create-index\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Index\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-index\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL CREATE INDEX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL CREATE INDEX","description":"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/","og_locale":"en_US","og_type":"article","og_title":"MySQL CREATE INDEX","og_description":"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/","og_site_name":"MySQL Tutorial","article_modified_time":"2023-12-29T08:54:14+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/","url":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/","name":"MySQL CREATE INDEX","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png","datePublished":"2009-12-27T09:37:26+00:00","dateModified":"2023-12-29T08:54:14+00:00","description":"In this tutorial, you will learn about indexes and how to use the MySQL CREATE INDEX statement to add an index to a table.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2018\/08\/MySQL-Index-example.png","width":250,"height":217,"caption":"MySQL Index example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-index\/mysql-create-index\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Index","item":"https:\/\/www.mysqltutorial.org\/mysql-index\/"},{"@type":"ListItem","position":3,"name":"MySQL CREATE INDEX"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=191"}],"version-history":[{"count":3,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/191\/revisions"}],"predecessor-version":[{"id":13805,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/191\/revisions\/13805"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/6818"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}