How to add values to other columns
Table with 8 columns. One row with only two columns have values other don't. How to add values to other columns?
UPDATE TABLE, INSERT INTO TABLE, ALTERTABLE?
I know how to do it with 'Update' and 'Insert into'.
I don't know how to do with 'Alter Table'.
Can any one answer my question please?
Thanks in advance
Re: How to add values to other columns
[QUOTE=Mohamed_Rafi;11890]Table with 8 columns. One row with only two columns have values other don't. How to add values to other columns?
UPDATE TABLE, INSERT INTO TABLE, ALTERTABLE?
I know how to do it with 'Update' and 'Insert into'.
I don't know how to do with 'Alter Table'.
Can any one answer my question please?
Thanks in advance[/QUOTE]
Hi Rafi
Use this query and solve your problem
UPDATE table_name
SET column_name(which is to be updated) = new_value
WHERE column1_name(any existing column) = any existing value;
NOte: the new_value if is a number then there is no need to put it in single quotes but if the data type of that column(to be updated) is VARCHAR2 then put the new_value in single quotes.
Re: How to add values to other columns
Hi Rafi,
As alter is a DDL command,you can not manipulate the table using alter.if you have to add one more column in table then u can make use of this.
but if you want to fill the columns of the table then you must have to use DML commands that is INSERT or UPDATE.
Re: How to add values to other columns
[QUOTE=reetasharma108;11978]Hi Rafi,
As alter is a DDL command,you can not manipulate the table using alter.if you have to add one more column in table then u can make use of this.
but if you want to fill the columns of the table then you must have to use DML commands that is INSERT or UPDATE.[/QUOTE]
hi reeta
i jus thought that if we want to insert(not as SQL command) values into a particular cell then then it is better to use UPDATE as INSERT will add a row to the (means a record to the table)..
please correct me if i am wroooooooooong:-)
Re: How to add values to other columns
ya.if u want to fill a colum u have to use update and for inserting new row then use insert.
Re: How to add values to other columns
Alter is a DDL command,you can not manipulate the table using alter. Need to use either update or insert into query to fill other column values.
Re: How to add values to other columns
before i tell u how to do that using ALTER command can u please tell me how can u do the same using INSERT.
Re: How to add values to other columns
hi i m ur friends please first write craete table something as select from that table name and write field name also
Re: How to add values to other columns
hi
ALTER TABLE table_name
ADD column_name datatype
or
INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)
or
UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value
Re: How to add values to other columns
Hello Friend,
Just go through this link once.
[BR][COLOR="Blue"][B][url=http://www.tomjewett.com/dbdesign/dbdesign.php?page=ddldml.php]Database Design - DDL & DML[/url][/B][/COLOR][BR]
I hope you will get your answer here.
Have a pleasant time.
Re: How to add values to other columns
The solution to your problem is using update command, as you know how to use update command no problem to find solution, just identify the unique row that is to be altered and update that column.
Main purpose of alter command is used to alter the columns of the existing table.
Syntax:
alter table table_name add column_name datatype
example: alter table person add city varchar(30)
Syntax:
alter table table_name drop column column_name
example: alter table person drop column address
and insert will create a new row into the exsiting table.