Oracle Alter Table | Alter Table Oracle - oracle tutorial - sql tutorial

Learn oracle - oracle tutorial - Oracle drop column of a table - oracle examples - oracle programs
What is Alter Table Statement in oracle ?
- Alter Table Statement specifies how to add, modify, drop or delete columns in a table.
- It is also used to rename a table.
Syntax:
ALTER TABLE TABLE_name
ADD COLUMN_name column-definition;
click below button to copy the code. By - oracle tutorial - team
Example:
- Add a new column address into the table customers.

Learn oracle - oracle tutorial - Oracle alter table - oracle examples - oracle programs
ALTER TABLE wikitechy_employee
ADD ADDRESS Varchar(30);
click below button to copy the code. By - oracle tutorial - team

- Using the “Alter Query“ in this the table “wikitechy_employee” the new column “ADDRESS” has been added.
- Alter Query has been executed and the output is shown above.
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql

Learn oracle - oracle tutorial - Oracle alter table with modify not null - oracle examples - oracle programs
MODIFY COLUMN OF A TABLE:
- To modify the column in a table, we have the syntax as follows:
Syntax:
Alter Table Table_Name
Modify Column_Name Column_Type;
click below button to copy the code. By - oracle tutorial - team
Example:
Alter Table Customers
Modify Customer_Name Varchar2(100) Not Null;
click below button to copy the code. By - oracle tutorial - team

- Alter Query is used to Change the name as a not null constraint in the “wikitechy_employee” table.
RENAME COLUMN OF A TABLE:
- The RENAME COLUMN statement allows you to rename an existing column in an existing table (ie)old name to new name in the table.

Learn oracle - oracle tutorial - Oracle alter table rename column - oracle examples - oracle programs
Syntax:
ALTER TABLE table_name
RENAME COLUMN old_name to new_name;
click below button to copy the code. By - oracle tutorial - team
Example:
ALTER TABLE customers
RENAME COLUMN customer_name to cname;
click below button to copy the code. By - oracle tutorial - team

- By Using Rename Statement the column name has been changed from old name(“City”) to new name as(“place”) in the Wikitechy_employee table .

- Since the Output of Rename statement as been changed from old name to new name column in the “wikitechy_employee” table, so we have executed the select statement to view the table.
oracle tutorial , sql tutorial , sql , pl sql tutorial , oracle , pl sql , plsql
DROP COLUMN OF A TABLE:
- It is used to drop a column in an existing table.
Syntax:
ALTER TABLE table_name
DROP COLUMN column_name;
click below button to copy the code. By - oracle tutorial - team
Example:
ALTER TABLE Wikitechy_employee
DROP COLUMN Position;
click below button to copy the code. By - oracle tutorial - team

- By Using Drop Statement the column “Position” will be deleted from the “wikitechy_employee” table.

- Since the Output of Drop Statement has been deleted from “wikitechy_employee” table.