Teradata Alter Table Drop Column

Teradata Alter Table Drop Column statement is used to drop an existing column from a Teradata table. You can also drop multiple columns in one statement using Alter Table Drop Column.

Teradata Alter Table Drop Column Syntax

The syntax of Teradata ALTER TABLE DROP COLUMN is as below.

ALTER TABLE database_name.tbl_name DROP column_name;

The syntax for dropping multiple column is as follows.

ALTER TABLE database_name.tbl_name 
                            DROP column_name1,
                            DROP column_name2
                            ....
                            DROP column_name(n);

Teradata ALTER TABLE DROP COLUMN Example

Consider the employee table with below definition.

show table Teradatapoint.employee;

CREATE SET TABLE Teradatapoint.employee ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO,
MAP = TD_MAP1
(
empid INTEGER,
empname VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC,
hobbies VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC DEFAULT 'Listen to Music',
native_place VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL)
)
UNIQUE PRIMARY INDEX ( empid );

Dropping one column example in Teradata

The below example drops the empname column from the employee table.

ALTER TABLE Teradatapoint.employee 
                             DROP empname;

Dropping multiple columns example in Teradata

The below example drops the hobbies and native_place column from the employee table.

ALTER TABLE Teradatapoint.employee 
                             DROP hobbies,
                             DROP native_place;

Now, if you check the table definition of employee table, you will see as below:

show table Teradatapoint.employee;

CREATE SET TABLE Teradatapoint.employee ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO,
MAP = TD_MAP1
(
empid INTEGER
)
UNIQUE PRIMARY INDEX ( empid );

Summary: In this tutorial, you have learned how to a single column and multiple column from a Teradata table.

Also Read:- 

  1. Add new column in Teradata Table
  2. Modify column in Teradata

Leave a Comment