How to add a new column Address in the above DB2 table TAB1?

DB2DatabaseBig Data Analytics

We can add a new column in an existing table as per the business requirements. Similarly, we can also remove a column from the table. This could be done using the ALTER table command as below.

ALTER TABLE TAB1
ADD COLUMN ADDRESS VARCHAR(100);

The ALTER TABLE reserved words are followed by the name of the table which we want to amend. In this case it is TAB1.

To add a new column we will use ADD COLUMN and to remove the column we will use the REMOVE COLUMN parameter. This is followed by the name of the column. If this is an addition of a new column then we also need to give the data type for this column.

raja
Published on 11-Sep-2020 14:41:49
Advertisements