Results 1 to 11 of 11

Thread: How to add values to other columns

  1. #1
    Junior Member
    Join Date
    May 2007
    Answers
    1

    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


  2. #2
    Contributing Member
    Join Date
    Jan 2007
    Answers
    33

    Re: How to add values to other columns

    Quote Originally Posted by Mohamed_Rafi View Post
    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
    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.


  3. #3
    Contributing Member
    Join Date
    Apr 2007
    Answers
    46

    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.


  4. #4
    Contributing Member
    Join Date
    Jan 2007
    Answers
    33

    Re: How to add values to other columns

    Quote Originally Posted by reetasharma108 View Post
    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.
    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:-)


  5. #5
    Contributing Member
    Join Date
    Apr 2007
    Answers
    46

    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.


  6. #6

    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.


  7. #7
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    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.


  8. #8
    Junior Member
    Join Date
    Jul 2007
    Answers
    1

    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


  9. #9
    Junior Member
    Join Date
    Mar 2008
    Answers
    6

    Smile 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


  10. #10
    Contributing Member
    Join Date
    Nov 2007
    Answers
    53

    Re: How to add values to other columns

    Hello Friend,

    Just go through this link once.

    [BR]Database Design - DDL & DML[BR]

    I hope you will get your answer here.

    Have a pleasant time.


  11. #11
    Junior Member
    Join Date
    Mar 2008
    Answers
    4

    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.

    Last edited by ManjuPillae; 03-27-2008 at 12:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
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.
Interact