Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Posts
    41

    Unanswered: adding COLUMNS to Table

    Hi All,

    I have created a Table T with two columns A and C,
    Now i want to add one more column B to it,
    I can add by using alter table, but can i add column B in the second position.

    i mean table T has columns
    A
    B

    after adding b table T should have fields like this
    A
    B
    C


    is it possible to add columns to a table in the required position.
    if YES pls guide me how to do it.

    Thanks In Advance
    'A candle will loose nothing by lighting an another candle'

  2. #2
    Join Date
    Feb 2004
    Posts
    41

    Re: adding COLUMNS to Table

    sorry
    i mean table T has columns
    A
    C

    after adding B, table T should have fields like this
    A
    B
    C


    is it possible to add columns to a table in the required position.
    if YES pls guide me how to do it.

    Thanks In Advance
    'A candle will loose nothing by lighting an another candle'

  3. #3
    Join Date
    Jan 2004
    Posts
    370
    No.

    Columns are added at the end.

    You'd need to recreate the table to do what you want.

  4. #4
    Join Date
    Feb 2004
    Posts
    41
    so u mean we can't interchange the position of a column.

    ok. thank u.
    'A candle will loose nothing by lighting an another candle'

  5. #5
    Join Date
    Feb 2004
    Posts
    41
    could u pls tell me if any specific or valid reasons for not able to insert column in a required positions.

    thank u very much for spending ur time.
    'A candle will loose nothing by lighting an another candle'

  6. #6
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by Sowmyam
    could u pls tell me if any specific or valid reasons for not able to insert column in a required positions.

    thank u very much for spending ur time.
    Can you give a valid reason why you should be able to? Column position is meaningless in tables, you are free to select them in any order you choose. Obviously, adding them "at the end" is the easiest for the DBMS, because it doesn't have to reorganize every existing row in the table to do so.

    You could always use a view to present the columns in your order of choice.

  7. #7
    Join Date
    Feb 2004
    Posts
    41
    ok Thank u.
    'A candle will loose nothing by lighting an another candle'

  8. #8
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    well position of columns will not effect ue application.
    More over when u used alter comman to add column it will be always
    last column of the table.
    Another method is:
    Create table T_1
    (A NUMBER,
    B NUMBER,
    C NUMBER)

    Insert from T to table T_1,
    DROP TABLE T
    RENAME TABLE T_1 TO T

    THANKS,
    Pagnint
    (No need to search web before posting new question)

  9. #9
    Join Date
    Feb 2004
    Posts
    41
    This is ok, but i asked in alter table itself is it possible.
    ok we can't do it right. fine.

    thanks a lot
    'A candle will loose nothing by lighting an another candle'

Posting Permissions

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