# RazorSQL

## Query, Edit, Browse, and Manage Databases

- razorsql.com
- Contact

# Oracle Alter Table

The Oracle Alter Table Tool allows users to visually alter tables. The Alter Table Tool can generate and/or execute the SQL that corresponds to any table alterations specified by the user.

The following options are available for the Oracle Alter Table Tool.

Add Column - Adds a column to a table
Add Primary Key - Adds a primary key to a table
Add Foreign Key - Adds a foreign key to a table
Add Constraint - Adds a check constraint to a table
Add Sequence Trigger - Adds a trigger to the table to handle auto incrementing a column
Change Column Type - Changes the data type of a column
Drop Column - Drops a column from a table
Drop Constraint - Drops a check constraint from a table
Drop Primary Key - Drops a primary key from a table
Drop Foreign Key - Drops a foreign key from a table
Rename Table - Renames a table
Rename Column - Renames a column

Listed below are some sample SQL statements generated by the Alter Table Tool.

ALTER TABLE TESTUSER.EMPLOYEE ADD NEWCOL CHAR(25) NOT NULL
ALTER TABLE TESTUSER.EMPLOYEE ADD PRIMARY KEY (SSN)
ALTER TABLE TESTUSER.EMPLOYEE
ADD FOREIGN KEY (SSN)
REFERENCES TESTUSER.DEPARTMENT(DNUMBER)
CREATE OR REPLACE TRIGGER DNO_TRIGGER
BEFORE INSERT ON TESTUSER.EMPLOYEE
FOR EACH ROW
BEGIN
IF :new.DNO IS NULL THEN
SELECT TEST_SEQUENCE.nextval INTO :new.DNO FROM DUAL;
END IF;
END;