PopSQL

How to Add a Not Null Constraint in PostgreSQL

Not null constraints are a great way to add another layer of validation to your data. Sure, you could perform this validation in your application layer, but shit happens: somebody will forget to add the validation, somebody will remove it by accident, somebody will bypass validations in a console and insert nulls, etc. If you're validating nulls on the database layer as well, you're protected 💪

alter table users alter column email set not null;
database icon
Real-time SQL collaboration is here
Get started with PopSQL and PostgreSQL in minutes