SQL – ALTER (Modify existing objects)

Spread the love

SQL – ALTER – modification in existing object like Table , Views , Stored Procedures , Functions etc.

Syntax –

Alter Table’s Columns add/drop

Alter Table TableName
Add/Drop ColumnName

Brand Table

S.NOPRODUCTMONTHYEARQTYSALES
1NIKEDEC2016107599
2REEBOKJAN2014181200
3FILAFEB201786000
4PUMAJAN2015165000
5REEBOKFEB2016209544
6FILAMAR201566252

 

Alter  Brand Table

S.NOPRODUCTMONTHYEARQTYSALES
1NIKEDEC2016107599
2REEBOKJAN2014181200
3FILAFEB201786000
4PUMAJAN2015165000
5REEBOKFEB2016209544
6FILAMAR201566252

 

Add a columns in existing table

ALTER TABLE BRAND
ADD PRODUCT_CODE CHAR(5)

S.NOPRODUCTMONTHYEARQTYSALESPRODUCT_CODE
1NIKEDEC2016107599NULL
2REEBOKJAN2014181200NULL
3FILAFEB201786000NULL
4PUMAJAN2015165000NULL
5REEBOKFEB2016209544NULL
6FILAMAR201566252NULL