LMSouq
database Open

How to add not null constraint to existing column in MySQL

MY
mymotherland
1 month ago
3 views
Problem Description
I have table name called "Person" with following column names P_Id(int), LastName(varchar), FirstName (varchar). I forgot to give `NOT NULL` Constraint to `P_Id`. Now I tried with following query to add `NOT NULL` Constraint to existing column called `P_Id`, 1. ALTER TABLE Person MODIFY (P_Id NOT NULL); 2. ALTER TABLE Person ADD CONSTRAINT NOT NULL NOT NULL (P_Id); I am getting syntax error....

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base