ALTER TABLE
Today I learned that creating a table is only the first step in SQL. Sometimes, after creating a table, we may realize that we need to change some rules. For example, maybe a column should not allo...

Source: DEV Community
Today I learned that creating a table is only the first step in SQL. Sometimes, after creating a table, we may realize that we need to change some rules. For example, maybe a column should not allow empty values, or maybe we want to add a new constraint later. For this, SQL gives us an important command called ALTER TABLE. ALTER TABLE is used when we want to change the structure of an existing table without deleting it and creating it again. In this blog, I am going to explain different ALTER TABLE tasks in a simple way. Making email compulsory in the customers table Suppose we already have a table called customers, and its email column currently allows NULL values. But now we want all future records to обязательно have an email value. For that, we can modify the column using: ALTER TABLE customers ALTER COLUMN email SET NOT NULL; What this does: This command makes the email field compulsory from now on. So, while inserting new records, we cannot leave the email empty. Making username