PL/SQL Add Column

To add a column to an existing table in Oracle PL/SQL, you can use the ALTER TABLE statement. The basic syntax is as follows:

ALTER TABLE table_name 
ADD (column_name datatype [NULL | NOT NULL] [DEFAULT value]);

Table Students

STUDENT_IDFIRST_NAMELAST_NAMEGENDERCITY
1DanielSCOTTMNew York
2AnthonySIMMONSMChicago
3SophiaTHOMPSONFLos Angeles

Add single column to table

For example, to add a column named “country” with a datatype of VARCHAR2(150) and a default value of ‘N/A’ to a table named “STUDENTS”, you would use the following statement:

ALTER TABLE STUDENTS 
  ADD country VARCHAR2(150);

Add columns to table

Also you can add multiple columns to a table in a single ALTER TABLE statement by separating the column definitions with commas.

ALTER TABLE STUDENTS 
  ADD ( address VARCHAR2(4000),
        country VARCHAR2(150)
      );

Query the table

SELECT STUDENT_ID, FIRST_NAME, LAST_NAME, ADDRESS, COUNTRY FROM STUDENTS; 
STUDENT_IDFIRST_NAMELAST_NAMEADDRESSCOUNTRY
1DanielSCOTT
2AnthonySIMMONS
3SophiaTHOMPSON