Pages

Search This Blog ...

Wednesday, April 27, 2016

Alter Table in Oracle

  1. Create Table 
  2. Alter Table
In this second tutorial i'll be explain how to manage created table

     2. Alter Table
             Here there are many way to manage created table.
             Using this statement you can change the table's column, name of column as well as table,
      change the constraint, datatype, etc.
             The table must be in your own schema, or you must have ALTER object privilege on the table, or you must have ALTER ANY TABLE system privilege.

        Syntax :
ALTER TABLE table_nm [ ADD (column1 datatype constraint,..,columnn datatype constraint) | 
MODIFY (column1 datatype constraint,..,columnn datatype )  | 
DROP COLUMN   column_name  | 
RENAME COLUMN column_name TO new_name  ]  ;

 
  • ADD
              If you want to add new column in your created table then you can use it.
              You can add one or more then one column add in your created table.
              The example is given below
Column
Add Column
  • MODIFY
            If you did some thing wrong or you not need previous did column you can change those
        setting [ Constraint ].
           This example is given below,

Column
Modify Column

  • DROP 
              Using this cause you can delete those column witch is no longer need in the future.
              Before you delete the a particular column in your table to check doesn't have primary or 
       foreign key [ referential integrity] on this column.
              This example is given below,
column
Drop Column
  • RENAME
             This cause is used for change the column name as well as change the name of table.
             The Syntax of change the name of table as given below,

 ALTER TABLE table_name RENAME TO new_name;
         
             The example given below,
  1. RENAME COLUMN
    Column
    Rename Column
  2. RENAME TABLE
    Table
    Rename Table
  That's are the exploration of Altering Table.

No comments:

Post a Comment

Thank you for give me feedback : )