ALTER COMMAND syntaxes:----------------------
ADDING COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> ADD <COLUMNNAME> <DATATYPE>
EG: ALTER TABLE PARTY ADD JDATE DATE
DROPING COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> DROP <COLUMNNAME>
EG: ALTER TABLE PARTY DROP JDATE
INCREASING DATATYPE LENGH:
SYNTAX:ALTER TABLE <TABLENAME> ADD COLUMNNAME DATATYPE<NEWLENGTH>
EG: ALTER TABLE PARTY ADD PARTYNAME VARCHAR(50)
ADDING CONSTRAINT:
SYNTAX: ALTER TABLE <TABLENAME> ADD CONSTRAINT <CONSTRAINTAME> PRIMARY/UNIQUE/CHECK
/REFERENCES(COLUMNS OR EXPRESSION)
EG:ALTER TABLE PARTY ADD CONSTRAINT CHK_SAL CHECK (PARTYSAL>100000)
Note: to add primary key or unique the column should have not null defined on it.
EG: ALTER TABLE PARTY ADD CONSTRAINT uk UNIQUE(PARTYNAME)
MODIFYING CONSTRAINT:
SYNTAX: ALTER TABLE <TABLENAME> MODIFY CONSTRAINT <CONSTRAINTAME> PRIMARY/UNIQUE
/CHECK/REFERENCES
EG:ALTER TABLE PARTY MODIFY CONSTRAINT CHK_SAL
CHECK (PARTYSAL>100000 AND PARTYSAL<200000)
DROPING CONSTRAINT:
SYNTAX:ALTER TABLE <TABLENAME> DROP CONSTRAINT <CONSTRAINTNAME>
EG: ALTER TABLE PARTY DROP CONSTRAINT CHK_SAL
NO FALLBACK TO FALLBACK:
SYNTAX: ALTER TABLE <TABLENAME>,FALLBACK
EG: ALTER TABLE PARTY,FALLBACK
CHANGING DATA BLOCKSIZE:
SYNTAX:ALTER TABLE <TABLENAME>, DATABLOCKSIZE=<MEMORY>BYTES IMMEDIATE
EG: ALTER TABLE <TABLENAME>, DATABLOCKSIZE=1200 BYTES IMMEDIATE
RENAMING THE COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> RENAME <OLDNAME>TO <NEWNAME>
EG: ALTER TABLE PARTY RENAME PARTYCD TO PARTYCODE
RENAMING A TABLE:
SYN: RENAME TABLE <OLDTABLE> TO <NEW TABLE>
EG: RENAME TABLE PARTY TO PARTY_NEW
ADDING COMPRESS:
ALTER TABLE PARTY ADD PARTYCODE COMPRESS NULL;
ALTER TABLE PARTY ADD ACCOUNTTYPE COMPRESS 'sAVINGS';
ALTER TABLE PARTY ADD ACCOUNTTYPE COMPRESS 'sAVINGS','Current';
ADDING COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> ADD <COLUMNNAME> <DATATYPE>
EG: ALTER TABLE PARTY ADD JDATE DATE
DROPING COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> DROP <COLUMNNAME>
EG: ALTER TABLE PARTY DROP JDATE
INCREASING DATATYPE LENGH:
SYNTAX:ALTER TABLE <TABLENAME> ADD COLUMNNAME DATATYPE<NEWLENGTH>
EG: ALTER TABLE PARTY ADD PARTYNAME VARCHAR(50)
ADDING CONSTRAINT:
SYNTAX: ALTER TABLE <TABLENAME> ADD CONSTRAINT <CONSTRAINTAME> PRIMARY/UNIQUE/CHECK
/REFERENCES(COLUMNS OR EXPRESSION)
EG:ALTER TABLE PARTY ADD CONSTRAINT CHK_SAL CHECK (PARTYSAL>100000)
Note: to add primary key or unique the column should have not null defined on it.
EG: ALTER TABLE PARTY ADD CONSTRAINT uk UNIQUE(PARTYNAME)
MODIFYING CONSTRAINT:
SYNTAX: ALTER TABLE <TABLENAME> MODIFY CONSTRAINT <CONSTRAINTAME> PRIMARY/UNIQUE
/CHECK/REFERENCES
EG:ALTER TABLE PARTY MODIFY CONSTRAINT CHK_SAL
CHECK (PARTYSAL>100000 AND PARTYSAL<200000)
DROPING CONSTRAINT:
SYNTAX:ALTER TABLE <TABLENAME> DROP CONSTRAINT <CONSTRAINTNAME>
EG: ALTER TABLE PARTY DROP CONSTRAINT CHK_SAL
NO FALLBACK TO FALLBACK:
SYNTAX: ALTER TABLE <TABLENAME>,FALLBACK
EG: ALTER TABLE PARTY,FALLBACK
CHANGING DATA BLOCKSIZE:
SYNTAX:ALTER TABLE <TABLENAME>, DATABLOCKSIZE=<MEMORY>BYTES IMMEDIATE
EG: ALTER TABLE <TABLENAME>, DATABLOCKSIZE=1200 BYTES IMMEDIATE
RENAMING THE COLUMN:
SYNTAX: ALTER TABLE <TABLENAME> RENAME <OLDNAME>TO <NEWNAME>
EG: ALTER TABLE PARTY RENAME PARTYCD TO PARTYCODE
RENAMING A TABLE:
SYN: RENAME TABLE <OLDTABLE> TO <NEW TABLE>
EG: RENAME TABLE PARTY TO PARTY_NEW
ADDING COMPRESS:
ALTER TABLE PARTY ADD PARTYCODE COMPRESS NULL;
ALTER TABLE PARTY ADD ACCOUNTTYPE COMPRESS 'sAVINGS';
ALTER TABLE PARTY ADD ACCOUNTTYPE COMPRESS 'sAVINGS','Current';