ALTER TABLE MODIFY

Oracle ALTER TABLE MODIFY

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

ALTER TABLE MODIFY

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

SQL> desc ocptech;

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

You Must read how to create SEQUENCE step by step

Modify Column

Suppose i want to change datatype of DETAILS columns in above table, so we are using 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 alter command we can add or remove columns from table, using following query we can add a new column in ocptech table.

SQL> alter table ocptech add xyz number;
ALTER TABLE MODIFY

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.
ALTER TABLE MODIFY

You Can subscribe my YouTube channel

Share

1 thought on “Oracle ALTER TABLE MODIFY”

Leave a Comment

Share