![]() ![]() If we want to remove the NOT NULL constraint from the city column in orders table the following SQL can be used - ALTER TABLE orders ALTER COLUMN city DROP NOT NULL If we want to add the NOT NULL constraint to city column in orders table the following SQL can be used - ALTER TABLE orders ALTER COLUMN city SET NOT NULL If we want to change the name of an existing table the following SQL can be used - ALTER TABLE orders RENAME TO neworders If we want to change the name of column city to vendor_city in orders table the following SQL can be used. If we want to change the type of column cus_name and city from character to varchar in orders table the following SQL can be used - ALTER TABLE orders If we want to drop the column vendor_name from orders table the following SQL can be used. If we want to add a column named vendor_name type varchar in orders table the following SQL can be used. Ord_qty numeric DEFAULT 1 CHECK(ord_qty>0 AND ord_qtyord_date) Item_grade character(1)NOT NULL DEFAULT 'A', The default value for a column can be removed.Data type of column(s) can be changed and the associating indexes and constraints will automatically be converted to new column type.If table referenced by other table CASCADE can be used. If indexes and any table constraints associated the involving column will automatically be dropped. The action to be done by this statement are as follows. The PostgreSQL ALTER TABLE statement is used to change the definition or structure of an existing table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |