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
Better SQL for the people
Get more done with PopSQL and PostgreSQL