{"id":8507,"date":"2025-06-16T04:51:56","date_gmt":"2025-06-16T04:51:56","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8507"},"modified":"2025-08-07T04:16:55","modified_gmt":"2025-08-07T04:16:55","slug":"how-to-alter-column-from-null-to-not-null","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/","title":{"rendered":"How To Alter Column From NULL to NOT NULL"},"content":{"rendered":"\n<p>All database systems allow you to store NULL as well as non NULL values. Sometimes you may need to change a nullable column with NULL values into one without NULL values. This may be because many filters and conditions do not work properly with NULL values. It may be also because you do not want to allow NULL values in certain database columns due to changes in business rules. Also, Null values can cause problems in <a href=\"\/data-analysis-tool\">data analysis &amp; reporting<\/a>. In this article, we will look at how to alter column from NULL to NOT NULL values. You can use these steps to change column from NULL to NOT NULL in MySQL, PostgreSQL and SQL Server.<\/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-alter-column-from-null-to-not-null\/#How_To_Alter_Column_From_Null_to_Not_Null\" >How To Alter Column From Null to Not Null<\/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-alter-column-from-null-to-not-null\/#1_Update_Table_to_Remove_Null_Values\" >1. Update Table to Remove Null Values<\/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-alter-column-from-null-to-not-null\/#2_Alter_Table_and_Modify_Column\" >2. Alter Table and Modify Column<\/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-alter-column-from-null-to-not-null\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Alter_Column_From_Null_to_Not_Null\"><\/span>How To Alter Column From Null to Not Null<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to alter column from NULL to NOT NULL. Let&#8217;s say you have a table <em>sales(id, amount, order_date)<\/em>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; create table sales(id int, amount int,order_date date);<br><br>mysql&gt; insert into sales(id, amount)<br>       values(1, 100),(2,300),(3,45);<br><br>mysql&gt; insert into sales(id, order_date)<br>       values(4,'2020-11-01');<br><br>mysql&gt; select * from sales;<br>+------+--------+------------+<br>| id   | amount | order_date |<br>+------+--------+------------+<br>|    1 |    100 | NULL       |<br>|    2 |    300 | NULL       |<br>|    3 |     45 | NULL       |<br>|    4 |   NULL | 2020-11-01 |<br>+------+--------+------------+<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Update_Table_to_Remove_Null_Values\"><\/span>1. Update Table to Remove Null Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before you run ALTER TABLE statement to convert a nullable column into not nullable one, you need to change all its NULL values to non-null ones. Otherwise, you will get an error. This is because you can change column to be NOT NULL only when already non of its values are NULL. Therefore, the first step is to remove null values from our column using UPDATE statement.<\/p>\n\n\n\n<p>As you can see, the above table contains null values in <em>order_date<\/em> and <em>amount<\/em> columns.<\/p>\n\n\n\n<p>Let us say you want to change amount column from null to not null. So first we will remove null values from this column using UPDATE statement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update sales set amount=0 <br>       where amount is null;<br><br>mysql&gt; select * from sales;<br>+------+--------+------------+<br>| id   | amount | order_date |<br>+------+--------+------------+<br>|    1 |    100 | NULL       |<br>|    2 |    300 | NULL       |<br>|    3 |     45 | NULL       |<br>|    4 |      0 | 2020-11-01 |<br>+------+--------+------------+<\/pre>\n\n\n\n<p>Similarly, if you want to change <em>order_date<\/em> column from null to not null, first update null values to not null values, as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; update sales set order_date='0000-00-00' \n       where order_date is null;\n\nmysql&gt; select * from sales;\n+------+--------+------------+\n| id   | amount | order_date |\n+------+--------+------------+\n|    1 |    100 | 0000-00-00 |\n|    2 |    300 | 0000-00-00 |\n|    3 |     45 | 0000-00-00 |\n|    4 |      0 | 2020-11-01 |\n+------+--------+------------+<\/pre>\n\n\n\n<p>Depending on the existing data type of your column (number or date), you need to accordingly set it to non-null value. In our examples, we have set int column to 0 and date column to &#8216;0000-00-00&#8217;. If your column is a text or string, then you need to set an appropriate non-null string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Alter_Table_and_Modify_Column\"><\/span>2. Alter Table and Modify Column<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Next, we will change amount column from null to not null, using ALTER TABLE statement. You can run this statement only when none of the values of a column are null. Here is the syntax for it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ALTER TABLE table_name ALTER COLUMN col_name data_type NOT NULL;<\/code><\/pre>\n\n\n\n<p>Replace table_name, col_name and data_type with table name, column name and data type respectively.<\/p>\n\n\n\n<p>Here&#8217;s the SQL query to change amount column from NULL to NOT NULL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">For MySQL\n---------\nALTER TABLE sales\nMODIFY COLUMN amount int NOT NULL;\n\nFor SQL Server\/PostgreSQL\n-------------------------\nALTER TABLE sales\nALTER COLUMN amount int NOT NULL;<\/pre>\n\n\n\n<p>Similarly, here are the SQL queries to change order_date column from NULL to NOT NULL<\/p>\n\n\n\n<pre id=\"block-9856ca30-8619-4d61-ad89-ad217e02b729\" class=\"wp-block-preformatted\">For MySQL\n---------\nALTER TABLE sales\nMODIFY COLUMN order_date date NOT NULL;\n\nFor SQL Server\/PostgreSQL\n-------------------------\nALTER TABLE sales\nALTER COLUMN order_date date NOT NULL;<\/pre>\n\n\n\n<p>We verify the above change by running the describe table command in MySQL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql&gt; describe sales;<br>+------------+---------+------+-----+---------+-------+<br>| Field      | Type    | Null | Key | Default | Extra |<br>+------------+---------+------+-----+---------+-------+<br>| id         | int(11) | YES  |     | NULL    |       |<br>| amount     | int(11) | <strong>NO<\/strong>   |     | NULL    |       |<br>| order_date | date    | <strong>NO<\/strong>   |     | NULL    |       |<br>+------------+---------+------+-----+---------+-------+<\/pre>\n\n\n\n<p>You will see that columns amount and order_date contain NO value for NULL column indicating that they are not permitted to store NULL values. <\/p>\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 change a column from NULL to NOT NULL. Often, many database administrators need to change <a href=\"https:\/\/www.dbvis.com\/thetable\/mysql-nullable-columns-everything-you-need-to-know\/\" target=\"_blank\" rel=\"noreferrer noopener\">nullable columns<\/a> to NOT null. It is important to remember that there are two steps involved instead of a single command for it. Also, when you update the present null values of the column to non-null value, you need to choose the appropriate value(0\/&#8217;0000-00-00&#8242;) depending on its data type (int\/date). Only after this step, you can use ALTER TABLE statement to convert the column to NOT NULL type.<\/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\/how-to-import-sql-file-in-mysql\/\">How to Import SQL File in MySQL<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-concatenate-multiple-mysql-rows-into-one-field\/\">How to Concatenate Multiple MySQL Rows into Single Column<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-see-foreign-keys-related-to-table-or-column\/\">How to See Foreign Keys Related to Table or Column<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.<\/p>\n","protected":false},"author":1,"featured_media":8509,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324,348,359],"tags":[476,477],"class_list":["post-8507","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","category-postgresql","category-sql","tag-alter-table","tag-null-to-not-null"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Alter Column From NULL to NOT NULL - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.\" \/>\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-alter-column-from-null-to-not-null\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Alter Column From NULL to NOT NULL - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/\" \/>\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=\"2025-06-16T04:51:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-07T04:16:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"301\" \/>\n\t<meta property=\"og:image:height\" content=\"201\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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-alter-column-from-null-to-not-null\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Alter Column From NULL to NOT NULL\",\"datePublished\":\"2025-06-16T04:51:56+00:00\",\"dateModified\":\"2025-08-07T04:16:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/\"},\"wordCount\":621,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/null-to-not-null.jpg?fit=301%2C201&ssl=1\",\"keywords\":[\"alter table\",\"null to not null\"],\"articleSection\":[\"MySQL\",\"PostgreSQL\",\"SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/\",\"name\":\"How To Alter Column From NULL to NOT NULL - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/null-to-not-null.jpg?fit=301%2C201&ssl=1\",\"datePublished\":\"2025-06-16T04:51:56+00:00\",\"dateModified\":\"2025-08-07T04:16:55+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/null-to-not-null.jpg?fit=301%2C201&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/null-to-not-null.jpg?fit=301%2C201&ssl=1\",\"width\":301,\"height\":201,\"caption\":\"null to not null\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-alter-column-from-null-to-not-null\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Alter Column From NULL to NOT NULL\"}]},{\"@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 Alter Column From NULL to NOT NULL - Ubiq BI","description":"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.","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-alter-column-from-null-to-not-null\/","og_locale":"en_US","og_type":"article","og_title":"How To Alter Column From NULL to NOT NULL - Ubiq BI","og_description":"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-06-16T04:51:56+00:00","article_modified_time":"2025-08-07T04:16:55+00:00","og_image":[{"width":301,"height":201,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg","type":"image\/jpeg"}],"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-alter-column-from-null-to-not-null\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Alter Column From NULL to NOT NULL","datePublished":"2025-06-16T04:51:56+00:00","dateModified":"2025-08-07T04:16:55+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/"},"wordCount":621,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg?fit=301%2C201&ssl=1","keywords":["alter table","null to not null"],"articleSection":["MySQL","PostgreSQL","SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/","name":"How To Alter Column From NULL to NOT NULL - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg?fit=301%2C201&ssl=1","datePublished":"2025-06-16T04:51:56+00:00","dateModified":"2025-08-07T04:16:55+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Here is how to change column from NULL to NOT NULL in SQL Server, MySQL, PostgreSQL using ALTER TABLE statement.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg?fit=301%2C201&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/06\/null-to-not-null.jpg?fit=301%2C201&ssl=1","width":301,"height":201,"caption":"null to not null"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-alter-column-from-null-to-not-null\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Alter Column From NULL to NOT NULL"}]},{"@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\/2025\/06\/null-to-not-null.jpg?fit=301%2C201&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-2dd","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8507","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=8507"}],"version-history":[{"count":4,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8507\/revisions"}],"predecessor-version":[{"id":8935,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8507\/revisions\/8935"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8509"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}