4
Reply

How to add a new column to an existing table?

Sapna Malik

Sapna Malik

13y
4k
0
Reply

    Alter Table Tablename Add columnname datatype

    alter table table_name add column_name data_type

    SQL: ALTER TABLE emp ADD DateOfBirth date

    To insert the new column after a specific column, such as name, use this statement:

    MySQl:

    ALTER TABLE abc ADD empname  VARCHAR(60) AFTER deptname;

    If you want the new column to be first, use this statement:
    ALTER TABLE abc ADD empname VARCHAR(60) FIRST;

    Renaming a table
    ALTER TABLE abc RENAME TO xyz

    SQL> Alter table table_name (id number, name varchar2(20));