โ— LIVE
OpenAI releases GPT-5 APIIndia AI startup raises $120MBitcoin ETF hits record inflowsMeta Llama 4 benchmarks leakedOpenAI releases GPT-5 APIIndia AI startup raises $120MBitcoin ETF hits record inflowsMeta Llama 4 benchmarks leaked
๐Ÿ“… Sun, 29 Mar, 2026โœˆ๏ธ Telegram
AiFeed24

AI & Tech News

๐Ÿ”
โœˆ๏ธ Follow
๐Ÿ Home๐Ÿค–AI๐Ÿ’ปTech๐Ÿš€Startupsโ‚ฟCrypto๐Ÿ”’Security๐Ÿ‡ฎ๐Ÿ‡ณIndiaโ˜๏ธCloud๐Ÿ”ฅDeals
โœˆ๏ธ News Channel๐Ÿ›’ Deals Channel
Home/Cloud & DevOps/Alter Tables
โ˜๏ธCloud & DevOps

Alter Tables

Hi! 1. You have a table customers with a column email that currently allows NULL values. Modify the table so that future entries must always have an email. ALTER TABLE customers ALTER COLUMN email SET NOT NULL; here the alter is used to set the column email that should not be blank. 2. In the users

โšกQuick SummaryAI generating...
A

Anjana R.K.

๐Ÿ“… Mar 29, 2026ยทโฑ 3 min readยทDev.to โ†—
โœˆ๏ธ Telegram๐• TweetWhatsApp
๐Ÿ“ก

Original Source

Dev.to

https://dev.to/anjana_rk_fbdea7abbdf13/alter-tables-3ag5
Read Full โ†—

Hi!
1. You have a table customers with a column email that currently allows NULL values. Modify the table so that future entries must always have an email.

ALTER TABLE customers ALTER COLUMN email SET NOT NULL;

here the alter is used to set the column email that should not be blank.
2. In the users table, ensure that the username column is unique across all records using an ALTER statement.

ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (username);

here an new contraint unique_name is used to keep unique user name thus ensure that the username column is unique across all records.
3. In the products table, enforce that price must always be greater than 0 using an ALTER command.

ALTER TABLE products ADD CONSTRAINT price CHECK (price>0);

here the table prducts is altered with price that has values greater than 0.
4. Modify the orders table so that the status column defaults to 'pending' if no value is provided during insertion.

ALTER TABLE orders ALTER COLUMN status SET DEFAULT 'pending';

the oders table is modified by setting the default value of status with pending.
5. Alter the employees table by adding a new column salary such that,It cannot be NULL,It must always be greater than 10,000

ALTER TABLE employees ADD COLUMN salary NOT NULL CHECK (salary>10000);

the column salary is added and it should not be null and check condition that salary >10000.
6. Modify the foreign key constraint between employees and departments so that when a department is deleted, all related employees are automatically removed.

ALTER TABLE employees ADD CONSTRAINT employees_department_id FOREIGN KEY (department_id) REFERENCES departments(id) ON DELETE CASCADE;

the on delete cascade is used so that when a department is deleted,all related employees are automatically removed .
7. In the accounts table, remove an existing CHECK constraint that enforces balance >= 0

ALTER TABLE accounts DROP CONSTRAINT accounts_balance;

8. In the payments table, ensure that the combination of user_id and transaction_id is unique using an ALTER TABLE statement.

ALTER TABLE payments ADD CONSTRAINT unique_transaction UNIQUE (user_id, transaction_id);

creates a Unique Constraint on table payments.It ensures that the exact same user_id and transaction_id combination can never be recorded twice, effectively preventing duplicate payment entries for the same transaction.

Tags:#cloud#dev.to

Found this useful? Share it!

โœˆ๏ธ Telegram๐• TweetWhatsApp

Read the Full Story

Continue reading on Dev.to

Visit Dev.to โ†—

Related Stories

โ˜๏ธ
โ˜๏ธCloud & DevOps

Stop Copying Skills Between Claude Code, Cursor, and Codex

about 6 hours ago

โ˜๏ธ
โ˜๏ธCloud & DevOps

Agentic Architectures โ€” Article 2: Advanced Coordination and Reasoning Patterns

about 6 hours ago

โ˜๏ธ
โ˜๏ธCloud & DevOps

Agentic Architectures โ€” Article 1: The Agentic AI Maturity Model

about 6 hours ago

โ˜๏ธ
โ˜๏ธCloud & DevOps

Reimagining Creativity: Inside IdeaForge

about 6 hours ago

๐Ÿ“ก Source Details

Dev.to

๐Ÿ“… Mar 29, 2026

๐Ÿ• about 6 hours ago

โฑ 3 min read

๐Ÿ—‚ Cloud & DevOps

Read Original โ†—

Web Hosting

๐ŸŒ Hostinger โ€” 80% Off Hosting

Start your website for โ‚น69/mo. Free domain + SSL included.

Claim Deal โ†’

๐Ÿ“ฌ AiFeed24 Daily

Top 5 AI & tech stories every morning. Join 40,000+ readers.

โœฆ 40,218 subscribers ยท No spam, ever

Cloud Hosting

โ˜๏ธ Vultr โ€” $100 Free Credit

Deploy cloud servers in 25+ locations. From $2.50/mo. No contract.

Claim $100 Credit โ†’
AiFeed24

India's AI-powered technology news platform. Curated from 60+ trusted sources, updated every hour.

โœˆ๏ธ @aipulsedailyontime (News)๐Ÿ›’ @GadgetDealdone (Deals)

Categories

๐Ÿค– Artificial Intelligence๐Ÿ’ป Technology๐Ÿš€ Startupsโ‚ฟ Crypto๐Ÿ”’ Security๐Ÿ‡ฎ๐Ÿ‡ณ India Techโ˜๏ธ Cloud๐Ÿ“ฑ Mobile

Company

About UsContactEditorial PolicyAdvertiseDealsAll StoriesRSS Feed

Daily Digest

Top AI & tech stories every morning. Free forever.

Privacy PolicyTerms & ConditionsCookie PolicyDisclaimerSitemap

ยฉ 2026 AiFeed24. All rights reserved.

Affiliate disclosure: We earn commissions on qualifying purchases. Learn more