
Alter Tables
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 customer ALTER COLUMN email SET NOT NULL ; 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 ); the reason we cant deal with this like previous question is because , unique is a table level property can not be alter as a column property so we add it as a constraint 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 CHECK ( price > 0 ); checking values can be can be updated only as a constraint 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' ; \ 5. Alter the employees table by ad
Continue reading on Dev.to
Opens in a new tab




