Just use an ALTER TABLE... MODIFY... query and add NOT NULL into your existing column definition. For example:

ALTER TABLE Person MODIFY P_Id INT(11) NOT NULL;

A word of caution: you need to specify the full column definition again when using a MODIFY query. If your column has, for example, a DEFAULT value, or a column comment, you need to specify it in the MODIFY statement along with the data type and the NOT NULL, or it will be lost. The safest practice to guard against such mishaps is to copy the column definition from the output of a SHOW CREATE TABLE YourTable query, modify it to include the NOT NULL constraint, and paste it into your ALTER TABLE... MODIFY... query.

Answer from Shakti Singh on Stack Overflow
๐ŸŒ
PopSQL
popsql.com โ€บ learn-sql โ€บ mysql โ€บ how-to-add-a-not-null-constraint-in-mysql
How to Add a Not Null Constraint in MySQL
To ensure that you do not miss anything, you can use the SHOW CREATE TABLE command to see the full column definition: mysql> SHOW CREATE TABLE products\G *************************** 1. row *************************** Table: products Create Table: CREATE TABLE `products` ( `product_id` bigint(20) NOT NULL, `product_name` varchar(100) DEFAULT '', `stocks` int(11) DEFAULT '0', (The rest of the output is truncated for brevity) Use the current definition and add NOT NULL for the correct modification:
Discussions

What happens when I put a NOT NULL constraint in MySQL while importing a CSV file and the file contains NULL values?
The latter. You would get an error with a constraint violation bc you are trying to insert a row with a null value in a column that does not allow nulls More on reddit.com
๐ŸŒ r/SQL
6
0
February 11, 2022
sql server - insert a NOT NULL column to an existing table - Stack Overflow
Since SQL Server supports ADD CONSTRAINT, I'd recommend Pavel's approach of creating a nullable column, and then adding a NOT NULL constraint after you've filled it with non-NULL values. ... MySQL supports adding non null columns into existing table with data, where the "sensible" empty value ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
NOT NULL & DEFAULT Constraints
try to think a few steps further how the db will be used. does the db-user have to add/select a value for the column? if not, should it be filled anyways? More on reddit.com
๐ŸŒ r/Database
6
0
April 10, 2023
Need some knowledge on NULL and NOT NULL
a null is used for multiple purposes -- for example, not known, not applicable, etc. theoreticians take great joy in debating which uses are valid, and whether they can be substituted by some non-null placeholder suffice to say, a null is used when you don't know what value should go there if you don't want that situation to arise, just make the column NOT NULL and you'll never be able to not insert an actual value More on reddit.com
๐ŸŒ r/SQL
32
14
December 23, 2021
๐ŸŒ
CastorDoc
castordoc.com โ€บ how-to โ€บ how-to-add-a-not-null-constraint-in-mysql
How to Add a NOT NULL Constraint in MySQL?
January 24, 2024 - By applying the NOT NULL constraint to this column, you ensure that every customer record must have a valid email address. This constraint prevents the insertion of records with missing or null email addresses, ensuring that your database only contains valid and complete customer information. When creating a table in MySQL, you can specify the NOT NULL constraint for a particular column.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ sql_notnull.asp
SQL NOT NULL Constraint
To define a NOT NULL constraint when creating a table, add NOT NULL after the data type of the column name.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ mysql โ€บ mysql-not-null-constraint
MySQL NOT NULL Constraint - GeeksforGeeks
July 23, 2025 - MySQL is a popular relational database ... to provide security and ensure the integrity of the stored data. There are various key constraints present in the table among these, the NOT NULL Constraint enforces the presence of values within specific columns. In this article, we will see the MySQL NOT NULL constraints, covering their implementation, addition, removal, ...
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to add a not null constraint in mysql
How to Add a NOT NULL Constraint in MySQL
1 month ago - To add a NOT NULL constraint to an existing MySQL column, first check for and resolve any NULL values in that column, then use ALTER TABLE ... MODIFY COLUMN column_name datatype NOT NULL.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ sql โ€บ sql-not-null-constraint.htm
SQL - NOT NULL Constraint
The DESCRIBE command provides a ... or not. You can add or remove the NOT NULL constraint on an existing table using the ALTER TABLE statement....
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ mysql โ€บ mysql_notnull.asp
MySQL NOT NULL Constraint
To define a NOT NULL constraint when creating a table, add NOT NULL after the data type of the column name. The following SQL creates a "Persons" table, and ensures that the "ID", "LastName", and "FirstName" columns cannot accept NULL values: ...
๐ŸŒ
Ubiq BI
ubiq.co โ€บ home โ€บ how to add not null constraint in mysql
How To Add NOT NULL Constraint in MySQL - Ubiq BI
July 18, 2024 - If you need to set a MySQL column ... can add NOT NULL constraint when you create table table using CREATE TABLE statement, or add NOT NULL constraint in existing table using ALTER TABLE statement....
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-add-not-null-constraint-to-existing-column-in-mysql
How to add not null constraint to existing column in MySQL?
Let us now implement the above syntax to implement the below query. Here, we are including "not null" constraint. mysql> ALTER table AddNotNUlldemo modify name varchar(100) not null; Query OK, 0 rows affected (1.14 sec) Records: 0 Duplicates: 0 Warnings: 0
๐ŸŒ
MySQL Tutorial
mysqltutorial.org โ€บ home โ€บ mysql basics โ€บ mysql not null constraint
MySQL NOT NULL Constraint
January 30, 2024 - However, you may want to add a NOT NULL constraint to a column of an existing table. In this case, you use the following steps: First, check the current values of the column if there are any NULL values. Second, update the NULL to non-NULL. Third, modify the column with a NOT NULL constraint.
๐ŸŒ
YouTube
youtube.com โ€บ watch
MySQL: NOT NULL constraint - YouTube
#MySQL #course #tutorial CREATE TABLE products ( product_id INT, product_name varchar(25), price DECIMAL(4, 2) NOT NULL);ALTER TABLE productsMODIFY
Published ย  October 18, 2022
๐ŸŒ
Programiz
programiz.com โ€บ sql โ€บ not-null
SQL NOT NULL Constraint (With Examples)
-- create table with NOT NULL constraint CREATE TABLE Colleges ( college_id INT NOT NULL, college_code VARCHAR(20), college_name VARCHAR(50) );
๐ŸŒ
CockroachDB Docs
cockroachlabs.com โ€บ docs โ€บ stable โ€บ not-null
NOT NULL constraint
You can only apply the NOT NULL constraint to individual columns. > CREATE TABLE IF NOT EXISTS customers ( customer_id INT PRIMARY KEY, cust_name STRING(30) NULL, cust_email STRING(100) NOT NULL ); > INSERT INTO customers (customer_id, cust_name, cust_email) VALUES (1, 'Smith', NULL); pq: null value in column "cust_email" violates not-null constraint
๐ŸŒ
Reintech
reintech.io โ€บ blog โ€บ sql-not-null-constraint-statement-detailed-guide
SQL 'NOT NULL CONSTRAINT' Statement: A Detailed Guide | Reintech media
February 19, 2026 - -- Step 1: Check for existing NULL ... ALTER TABLE Customers ALTER COLUMN Email SET NOT NULL; -- MySQL: ALTER TABLE Customers MODIFY Email varchar(255) NOT NULL; -- SQL Server: ALTER TABLE Customers ALTER COLUMN Email varchar(255) ...
๐ŸŒ
Reddit
reddit.com โ€บ r/sql โ€บ what happens when i put a not null constraint in mysql while importing a csv file and the file contains null values?
r/SQL on Reddit: What happens when I put a NOT NULL constraint in MySQL while importing a CSV file and the file contains NULL values?
February 11, 2022 -

I am importing data from a CSV file to MySQL for the first time. Many tutorials I have seen recommends putting a NOT NULL constraint to all of the columns. I am not certain if certain columns don't have NULL values so I am only putting the constraint where I am certain there are no NULL values. But I want to know what would happen if there are NULL values in a column where I put a NOT NULL constraint? Would the values just display 'NULL' or would there be an error in importing the file?

๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to use not null and default constraints in mysql
How to Use NOT NULL and DEFAULT Constraints in MySQL
1 month ago - CREATE TABLE products ( id INT ... ยท -- Add DEFAULT to an existing nullable column ALTER TABLE products MODIFY COLUMN stock_count INT UNSIGNED NOT NULL DEFAULT 0; -- Make a nullable column NOT NULL (first ensure no NULLs ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ sql โ€บ sql-not-null-constraint
SQL NOT NULL Constraint - GeeksforGeeks
February 10, 2026 - The syntax for applying the NOT NULL constraint can be as follows: CREATE TABLE table_Name ( column1 data_type(size) NOT NULL, column2 data_type(size) NOT NULL, ... ); You can also add a NOT NULL constraint to an existing column in a table using ...