Hello friends, In this article, we are going to discuss, how to use the ALTER TABLE ORACLE MODIFY column. Using this command we can modify table structure if required after table creation.

Alter Table Oracle Modify

In this practical we are using following table which has three columns.

SQL> desc ocptech;

  Name          Null?    Type
 ------------  ------   ----------
 ID                            NUMBER
 DETAILS                  VARCHAR2(60)
 J_DATE                    DATE

Modify Column

Suppose, I want to change the datatype of DETAILS columns in the above table, so we are using the following query.

SQL> alter table ocptech modify details number;

 Table altered.

Now check table structure, it is changed.

SQL> desc ocptech;

 Name          Null?    Type
----------  --------   --------
 ID                      NUMBER
 DETAILS                 NUMBER
 J_DATE                  DATE

Alter table Add Column

Using the alter command we can add or remove columns from the table, using the following query we can add a new column in ocptech table.

SQL> alter table ocptech add xyz number;

Alter table Drop Column

As we discuss above, Using following query we can remove a column.

SQL> alter table ocptech drop column xyz;

Table altered.
subscribe on youtube

Read – What is SQL, DBMS, and RDBMS


Leave a Comment

%d bloggers like this:
Enable Notifications    OK No thanks