Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2007

    Unanswered: Inserting values into a single column in oracle table

    Hi all,
    Can someone help me with a query.
    I have a table in oracle 10g database.

    1. I added a new column to that table and i want to populate that single column with values. i do not want to touch other columns but to populate that single added column with values

    2. In populating the rows of that single column, I want to populate each row based on a condition of values present in another column of that table.
    what i means is:
    suppose an already populated column in the table have values S, X, U, repeating throughtout the rows of that column, i want to populate the new column with values in each row based on if the corresponding row in the other column has values S or X or U.
    I hope i communicated well
    I would greatly appreciate a response ASAP
    Thanks all

  2. #2
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 5
    It is just an UPDATE statement; nothing special here, as far as I can tell.

    However, as you didn't say WHAT condition should that newly created column's value meet regarding the existing column, here is an example which will populate your new column with 1, 2 or 3 - depending on S, X or U value in another column. I believe that final solution may be derived from it.
    UPDATE this_table SET
      new_column = DECODE(sxu_column, 'S', 1, 'X', 2, 'U', 3);

  3. #3
    Join Date
    Nov 2007

    Thumbs down Inserting values into a single column in oracle table

    Thanks a lot again, it worked well
    You're just great

  4. #4
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    Not everything that can be done, should actually be done.
    IMO, this is a VERY BAD idea & violates 3rd Normal Form.
    What happens at a later time when the value of sxu_column gets updated.
    Are you going to have a trigger which now updates the new (derived) column?
    Why not just create a VIEW; rather than actually storing data?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Nov 2007
    Yap thanks,
    i got your point clear, but i'm not dealing with a transactional system. I'm dealing with datawarehouse kind of thing where historical records are kept. the historical records are not what the organization is likely to alter so the probability of updates is quite small. moreover i just created the table for other underlining tables

Posting Permissions

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