DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: can we alter the sequence of columns in a table?

  1. #1
    Join Date
    Feb 2001
    Posts
    114
    Hi all,
    can we alter the sequence of columns already defined in a table ?
    table emp has empno,ename,loc

    like empno,loc,ename ?


    if i have to drop a column, does it have to be empty ?

    thanks

  2. #2
    Join Date
    Jan 2001
    Posts
    3,134

    Lightbulb

    I am no expert but i think you have to re-create the table and then insert the data. At least this is one way of doing it.
    MH

  3. #3
    Join Date
    Feb 2001
    Posts
    114
    I think this should be good instead of dropping,recreating etc.
    for changing the column sequences.


    table A (1,2,3)

    create table b (3,2,1) as select (3,2,1) from A

  4. #4
    Join Date
    Mar 2001
    Posts
    314
    How about creating a view to achieve the same results?

    -amar

  5. #5
    Join Date
    Jul 2001
    Posts
    8
    Instead of just creating a view we can go for materialised view...

    --Sriram.

  6. #6
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Originally posted by pv_sriram
    Instead of just creating a view we can go for materialised view...

    --Sriram.
    And for what purpose, may I ask?
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  7. #7
    Join Date
    Nov 1999
    Posts
    226
    Not in my knowledge in the same table


    regards

  8. #8
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Originally posted by jmodic
    Originally posted by pv_sriram
    Instead of just creating a view we can go for materialised view...

    --Sriram.
    And for what purpose, may I ask?
    I'd take it another step further... why worry about the physical order of the columns at all? That is almost as bad as worrying about the physical order of the rows. It is irrelevant. Now, don't get me wrong - If you are interested simply because you're anal retentive (as am I) and like your db to match your model, then that's fine, as long as you understand that the order is *functionally* irrelevant. If the order of the columns *does* functionally affect you, then that means the you probably have INSERT statements without column lists and therefore the physical order is messing up your SQL. In that case - *fix the SQL*, if at all possible.


    - Chris

Posting Permissions

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


Click Here to Expand Forum to Full Width