Categories: DM & Database

Oracle Database Data Definition Language(DDL Statements) – ALTER Commands:

In this section, we will try to explain about important database ALTER commands that are used by a data modeler by relating it with our example data.

ALTER TABLE – Add column:

ALTER TABLE EMPLOYEE_DTL ADD JOIN_DATE DATE;

ALTER TABLE – Rename column:

ALTER TABLE EMPLOYEE_DTL RENAME column JOIN_DATE TO EMP_JOIN_DT;

ALTER TABLE – Modify column’s datatype:

ALTER TABLE EMPLOYEE_DTL MODIFY EMP_JOIN_DT VARCHAR2(10);

ALTER TABLE – Drop column:

ALTER TABLE EMPLOYEE_DTL DROP COLUMN EMP_JOIN_DT;

ALTER TABLE – Add check constraint:

ALTER TABLE EMPLOYEE_DTL ADD CONSTRAINT CH_SAL CHECK(SLRY_AMT BETWEEN 4000 AND 7000);

ALTER TABLE – Add unique constraint:

ALTER TABLE EMPLOYEE_DTL ADD CONSTRAINT UN_SSN UNIQUE(SSN);

ALTER TABLE – Disable/Enable/Drop constraint:

ALTER TABLE EMPLOYEE_DTL DISABLE CONSTRAINT UN_SSN;
ALTER TABLE EMPLOYEE_DTL ENABLE CONSTRAINT UN_SSN;
ALTER TABLE EMPLOYEE_DTL DROP CONSTRAINT UN_SSN;

ALTER TABLE – Modify constraint:

ALTER TABLE EMPLOYEE_DTL MODIFY SLRY_AMT NUMBER(7,2) NULL;
ALTER TABLE EMPLOYEE_DTL MODIFY SLRY_AMT NUMBER(7,2) NOT NULL;

learndmdwbi

Share
Published by
learndmdwbi

Recent Posts

Oracle’s Database Dictionary Views

These SQL commands are related with Oracle's data dictionary and can be used to get…

8 months ago

Oracle important DDL Statements

important DDL Statements from Oracle like Commit, Rollback, Grant, Revoke etc..

8 months ago

Oracle Database Data Definition Language(DDL Statements)- DROP Object Commands

In this section, we will try to explain about important database DROP commands that are…

8 months ago

Oracle Database Data Manipulation Language (DML) Commands

In this section, we will try to explain about important database DML commands that are…

8 months ago

Oracle DDL Statements – CREATE Commands

An Oracle database consists of DDL commands, which are useful to create, modify and drop…

8 months ago

Sample Data Analysis

Sample data for database analysis!

8 months ago