Altering a Table

Add a Column: To add a new column to an existing table:

ALTER TABLE table_name ADD column_name datatype;

Example

ALTER TABLE employees ADD email VARCHAR2(100);

Modify a Column: To change the datatype or constraints of an existing column:

ALTER TABLE table_name MODIFY column_name new_datatype;

Example

ALTER TABLE employees MODIFY salary NUMBER(10, 2);

Drop a Column: To remove a column from a table:

ALTER TABLE table_name DROP COLUMN column_name;

Example

ALTER TABLE employees DROP COLUMN email;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *