Interviews4 answers
How to add a new column to an existing table?
4 Answers
Alter Table Tablename
Add columnname datatype
Sanjeev KumarPosted Jul 27, 2016, 2:10 AM EDT
alter table table_name
add column_name data_type
Rahul PrajapatPosted May 27, 2015, 4:47 PM EDT
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
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
Jiteendra SampathiraoPosted May 24, 2011, 8:15 PM EDT
SQL> Alter table table_name (id number, name varchar2(20));
Sapna MalikPosted May 23, 2011, 8:11 PM EDT




