{"id":8530,"date":"2020-11-05T04:58:00","date_gmt":"2020-11-05T04:58:00","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8530"},"modified":"2025-08-25T04:51:18","modified_gmt":"2025-08-25T04:51:18","slug":"how-to-add-auto-increment-column-in-existing-table-in-mysql","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/","title":{"rendered":"How to Add Auto Increment Column in Existing Table in MySQL"},"content":{"rendered":"\n<p>Auto Increment columns automatically increase in value as you add more rows to the table. They are unique and sequential. They are generally defined at the time of table creation. But sometimes database administrators need to add such a column to an existing table. In this article we will look at how to add auto increment column in MySQL.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#Why_Add_Auto_Increment_Column_to_Table\" >Why Add Auto Increment Column to Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#How_to_Add_Auto_Increment_Column\" >How to Add Auto Increment Column<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#Add_Auto_Increment_Column_to_Existing_Table\" >Add Auto Increment Column to Existing Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#Add_Auto_Increment_Column_to_New_Table\" >Add Auto Increment Column to New Table<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#How_to_Set_Auto_Increment_Initial_Value\" >How to Set Auto Increment Initial Value<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Add_Auto_Increment_Column_to_Table\"><\/span>Why Add Auto Increment Column to Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Auto Increment columns are very useful since they are automatically populated with unique sequential numbers, one for each row. They act as a primary key or unique identifier for each row making it very easy to quickly select the specific row, if needed. Every database system supports auto increment columns and ensure unique values are automatically stored in them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Add_Auto_Increment_Column\"><\/span>How to Add Auto Increment Column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to add auto increment column in MySQL. Let&#8217;s say you have the following <em>sales(id, amount)<\/em> table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table sales(id int, amount int);\n\nmysql&gt; insert into sales(id,amount) \n       values(1, 100),(4,300),(6,400);\n\nmysql&gt; select * from sales;\n+------+--------+\n| id   | amount |\n+------+--------+\n|    1 |    100 |\n|    4 |    300 |\n|    6 |    400 |\n+------+--------+<\/pre>\n\n\n\n<p>There are 2 ways to add auto increment column &#8211; to an existing table, or during table creation. We will look at both these methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Add_Auto_Increment_Column_to_Existing_Table\"><\/span>Add Auto Increment Column to Existing Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, we will modify the <em>id<\/em> column to be auto increment, using ALTER TABLE.<\/p>\n\n\n\n<p>Here&#8217;s the syntax of ALTER TABLE statement,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ALTER TABLE table_name \nMODIFY column_name INT NOT NULL AUTO_INCREMENT PRIMARY KEY;<\/pre>\n\n\n\n<p>In the above statement, you need to specify the <em>table_name<\/em> and <em>column_name<\/em>.<\/p>\n\n\n\n<p>Here&#8217;s the SQL statement to add <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/example-auto-increment.html\" target=\"_blank\" rel=\"noreferrer noopener\">AUTO INCREMENT<\/a> constraint to <em>id<\/em> column. Please note, you can add auto increment constraint only to the primary key column of your table. Therefore, when you add such a column, you need to mention both AUTO_INCREMENT and &#8216;PRIMARY KEY&#8217; together.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ALTER TABLE sales\nMODIFY id INT NOT NULL AUTO_INCREMENT PRIMARY KEY;<\/pre>\n\n\n\n<p>Next we will add a couple of rows in sales table.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; insert into sales(amount) values(150),(250);\n\nmysql&gt; select * from sales;\n+----+--------+\n| id | amount |\n+----+--------+\n|  1 |    100 |\n|  4 |    300 |\n|  6 |    400 |\n|  7 |    150 |\n|  8 |    250 |\n+----+--------+<\/pre>\n\n\n\n<p>As you can see, the MySQL has automatically increased and populated <em>id<\/em> column with values 7 and 8.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Add_Auto_Increment_Column_to_New_Table\"><\/span>Add Auto Increment Column to New Table<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also add auto increment column during table creation. However, remember that, in this case, auto increment constraint can be assigned only to primary key column.<\/p>\n\n\n\n<p>Here&#8217;s the syntax to add auto increment column during table creation. It needs to be mentioned as a column constraint.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">create table <em>table_name<\/em>(<br>auto_increment_column_name int not null <strong>auto_increment<\/strong> primary key,<br>column2,<br>...);<\/pre>\n\n\n\n<p>Here&#8217;s an example to add auto increment column in MySQL<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table sales2(id int not null auto_increment primary key, \namount int);\n\nmysql&gt; insert into sales2(amount) values(100),(125),(250),(300);\n\nmysql&gt; select * from sales2;\n+----+--------+\n| id | amount |\n+----+--------+\n|  1 |    100 |\n|  2 |    125 |\n|  3 |    250 |\n|  4 |    300 |\n+----+--------+\n<\/pre>\n\n\n\n<p>As you can see above, the <em>id<\/em> column is automatically incremented and populated. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Set_Auto_Increment_Initial_Value\"><\/span>How to Set Auto Increment Initial Value<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By default, auto increment column value starts from 1. You can change auto increment start value if you want. Here&#8217;s the syntax for it,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>alter table <em>table_name<\/em> AUTO_INCREMENT=<\/code><em>increment_value<\/em><\/pre>\n\n\n\n<p>In the above SQL query, you need to specify the <em>table_name<\/em> as well as <em>increment_value<\/em>.<\/p>\n\n\n\n<p>For example, here&#8217;s the SQL query to set initial increment value to 100<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">alter table sales AUTO_INCREMENT=100<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt how to include an auto increment column to existing table in MySQL. There are two ways to add auto increment column. You can either add it during table creation or afterwards. We have learnt both these methods. Adding such a column may need you to re-think about your table indexes and constraints. Hopefully, the above article will help you add auto increment column in existing table in MySQL.<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a> makes it easy to visualize data, and monitor them in real-time dashboards. <a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a> for free.<\/p>\n\n\n\n<p>Also read:<br><a href=\"https:\/\/ubiq.co\/tech-blog\/top-5-free-database-design-tools\/\">Top Free Database Design Tools<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-replicate-mysql-database-to-another-server\/\">How to Replicate MySQL Database to Another Server<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-enable-ssl-tls-for-mysql-in-ubuntu\/\">How to Enable SSL\/TLS from MySQL in Ubuntu<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Auto increment column automatically increases on adding new rows. Here&#8217;s how to ad auto increment column in existing table in MySQL.<\/p>\n","protected":false},"author":1,"featured_media":8532,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324],"tags":[483],"class_list":["post-8530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","tag-auto-increment"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Auto increment column automatically increases on adding new rows. Here&#039;s how to ad auto increment column in existing table in MySQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Auto increment column automatically increases on adding new rows. Here&#039;s how to ad auto increment column in existing table in MySQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-05T04:58:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-25T04:51:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"730\" \/>\n\t<meta property=\"og:image:height\" content=\"410\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Add Auto Increment Column in Existing Table in MySQL\",\"datePublished\":\"2020-11-05T04:58:00+00:00\",\"dateModified\":\"2025-08-25T04:51:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\"},\"wordCount\":555,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1\",\"keywords\":[\"auto increment\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\",\"name\":\"How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1\",\"datePublished\":\"2020-11-05T04:58:00+00:00\",\"dateModified\":\"2025-08-25T04:51:18+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Auto increment column automatically increases on adding new rows. Here's how to ad auto increment column in existing table in MySQL.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1\",\"width\":730,\"height\":410,\"caption\":\"auto increment in mysql\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add Auto Increment Column in Existing Table in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI","description":"Auto increment column automatically increases on adding new rows. Here's how to ad auto increment column in existing table in MySQL.","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:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/","og_locale":"en_US","og_type":"article","og_title":"How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI","og_description":"Auto increment column automatically increases on adding new rows. Here's how to ad auto increment column in existing table in MySQL.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-05T04:58:00+00:00","article_modified_time":"2025-08-25T04:51:18+00:00","og_image":[{"width":730,"height":410,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp","type":"image\/webp"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Add Auto Increment Column in Existing Table in MySQL","datePublished":"2020-11-05T04:58:00+00:00","dateModified":"2025-08-25T04:51:18+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/"},"wordCount":555,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1","keywords":["auto increment"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/","name":"How to Add Auto Increment Column in Existing Table in MySQL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1","datePublished":"2020-11-05T04:58:00+00:00","dateModified":"2025-08-25T04:51:18+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Auto increment column automatically increases on adding new rows. Here's how to ad auto increment column in existing table in MySQL.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1","width":730,"height":410,"caption":"auto increment in mysql"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-add-auto-increment-column-in-existing-table-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Add Auto Increment Column in Existing Table in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/auto-increment-mysql.webp?fit=730%2C410&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2dA","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8530"}],"version-history":[{"count":2,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8530\/revisions"}],"predecessor-version":[{"id":9282,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8530\/revisions\/9282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8532"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}