We can add column in existing table in Teradata. But you may require it in the middle of the table of it is okey if you add it at the last of the table. When you required to add it in the middle of the table then you need to take a backup of table and then drop the table and recreate it and again insert the data from the backup table. But if you want to add column in the last of the table then you can simply add this by simple altering the definition of the table. Let's see how we can do it:-
ALTER TABLE TABLE_NAME ADD COLUMN_NAME DATA_TYPE (VALUE_LENGTH);
Let's say you have EMPLOYEE table and you need to add column ADDRESS column into it then you can do it like:-
ALTER TABLE EMPLOYEE ADD ADDR VARCHAR(20);
You can add multiple column in a table:-
Let's say you need to add ADDRESS AND PHONE NUMBER column to employee table then you can do it like:-
ALTER TABLE EMPLOYEE ADD ADDR VARCHAR(20), PHONE_NO INTEGER;
ALTER TABLE TABLE_NAME ADD COLUMN_NAME DATA_TYPE (VALUE_LENGTH);
Let's say you have EMPLOYEE table and you need to add column ADDRESS column into it then you can do it like:-
ALTER TABLE EMPLOYEE ADD ADDR VARCHAR(20);
You can add multiple column in a table:-
Let's say you need to add ADDRESS AND PHONE NUMBER column to employee table then you can do it like:-
ALTER TABLE EMPLOYEE ADD ADDR VARCHAR(20), PHONE_NO INTEGER;
No comments:
Post a Comment