# Databases > Oracle Add a new column to a table and insert values

## Ajit Kumar Maharatha

How can i add a new column to a table and insert values in that column
which will be beside the previous column?  like suppose i want to add a email address column to emp table and add email address of smith who is already a member of emp table ?

----------


## kalayama

It is simple task as long as your new column allows NULLs.
Take a back up of existing table and then go on to add the column.

select * intoo emp_backup from emp.

ALTER TABLE EMP 
ADD emp_email varchar2(40);

This will add the column emp_email to emp table.

Now to add a value to this column, you should use UPDATE statement. Simple as that.

Cheers!
Kalayama

----------


## yagnam ramesh babu

eg:-alter table emp add email_add varchar2(15);
this will insert the column email_add to your table.

----------


## niranjanareddy

Alter table emp add email_address varchar(30); --this will creates a column email_address. After creating column,update the table to insert the email address of the smith. I.e., update emp set email_address=' ' where ename='smith'; ok....bye... Kalayama

----------


## debasisdas

You need to execute 2 separate commands.
1. alter (DDL) table to add a new field to existing table.
2.Update (DML) the table to insert value to the new column.

----------


## susarlasireesha

Alter table tablename add(columnname datatype).With this command u can add the column.

----------


## aditi14

For add new col you need alter command 
SQL>alter table emp add (email varchar2(30));
For insert the value in this col according condition
SQL>update emp set email='gmail' where name='scott';

----------


## sunshine60india

For adding  column to the table...
ALTER TABLE table-name ADD column-name type(size);

For inserting data into added column
UPDATE table-name SET  column-name =value WHERE condition;

Thanks,, Vipul Patel

----------


## nehrumosuru

The following commands used for adding new column and inserting values to the table.

1. For adding column to the table

ALTER TABLE emp
ADD ( EMP_NAME VARCHAR(30));

2. For inserting data into table 

INSERT INTO emp(NAME)
VALUES ('VINAYAKA')

Regards

Nehru Mosuru

----------


## denniscodd

> It is simple task as long as your new column allows NULLs.
> Take a back up of existing table and then go on to add the column.
> 
> select * intoo emp_backup from emp.
> 
> ALTER TABLE EMP 
> ADD emp_email varchar2(40);
> 
> This will add the column emp_email to emp table.
> ...


what is table mutation error and what is the occation it will happen

----------


## krishnaindia2007

*>>what is table mutation error and what is the occation it will happen*

Follow the link

----------


## nathsambu

Alter table dept
add (ename varchar2(10));

 For insert the value in ename colomn,

Insert into dept (ename)
value('Deepa');
Try this. I think you will getting u r answer.

----------


## Sam S Kolta

1. Command for add a new column name emp_email
A. Syntax:
ALTER TABLE 
ADD  ;

B. Command
ALTER TABLE emp
ADD emp_email varchar2(40);

2. To add values to this column 
A. Syntax
UPDATE 
SET  = <'Value'>
WHERE = <'value'>;

B. Example:
UPDATE emp
SET emp_email = 'emp_smith@yahoo.com'
WHERE ename = 'SMITH';






  Reply With Quote



















«
Previous Thread
			|
			Next Thread
»







				Posting Permissions
			



You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
 



BB code is On
Smilies are On
[IMG] code is On
[VIDEO] code is On
HTML code is On


Forum Rules












About us
		Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
				

GeekInterview

GeekInterview
Learning Center
Online Quiz
Interview Questions
Interview Coaching
Interview eBook





Interact














Contact Us  |  
Geeks Discussions  |  
Archive  |  
Privacy Statement  |  
Top





All times are GMT -4. The time now is 01:38 PM.


	Powered by vBulletin™






	Search Engine Optimisation provided by 
			DragonByte SEO v2.0.37 (Lite) - 
			vBulletin Mods & Addons Copyright © 2023 DragonByte Technologies Ltd.Copyright © 2014 GeekInterview.com. All Rights Reserved

----------

