FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Alter Tables
How-ToMachine Learning

Alter Tables

via Dev.to TutorialSri Mahalakshmi2h ago

1. Make email NOT NULL in customers ALTER TABLE customers ALTER COLUMN email SET NOT NULL; Ensures all future records must have an email. 2. Make username unique in users ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (username); Prevents duplicate usernames. 3. Add CHECK on price in products ALTER TABLE products ADD CONSTRAINT check_price CHECK (price > 0); Ensures price is always greater than 0. 4. Set default status in orders ALTER TABLE orders ALTER COLUMN status SET DEFAULT 'pending'; Automatically assigns pending if no value is given. 5. Add salary column with constraints ALTER TABLE employees ADD COLUMN salary INT NOT NULL CHECK (salary > 10000); Ensures salary is mandatory and above 10,000. 6. Add ON DELETE CASCADE to foreign key ALTER TABLE employees DROP CONSTRAINT employees_department_id_fkey; ALTER TABLE employees ADD CONSTRAINT employees_department_id_fkey FOREIGN KEY (department_id) REFERENCES departments(id) ON DELETE CASCADE; Deletes employees automatically whe

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
0 views

Related Articles

How-To

Building a Runtime with QuickJS

Lobsters • 1h ago

I can't stop talking about the Ninja Creami Swirl - and it's on sale at Amazon right now
How-To

I can't stop talking about the Ninja Creami Swirl - and it's on sale at Amazon right now

ZDNet • 2h ago

How-To

Do Beginners Still Search "How to Code"?

Medium Programming • 2h ago

How to Become a Software Developer After 12th?
How-To

How to Become a Software Developer After 12th?

Medium Programming • 3h ago

Claude Code Essentials
How-To

Claude Code Essentials

FreeCodeCamp • 3h ago

Discover More Articles