Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2002
    Posts
    58

    Question Unanswered: Change column index

    Is there any way to change the order of fields in a table?
    Kind of like the column index in SQL Server.
    Thanks

  2. #2
    Join Date
    Oct 2003
    Location
    St.Louis,MO
    Posts
    120
    You could re-create as then drop the old table
    But, why does it matter what order they are in?
    you can select in any order.

  3. #3
    Join Date
    Feb 2002
    Posts
    58
    You're right, but really I am just curious. It makes the table easier to read when the columns that are common are adjacent to each other.

  4. #4
    Join Date
    Oct 2003
    Location
    St.Louis,MO
    Posts
    120
    ???? OK.
    create table tablename (column2,column1....)
    as select column2,column1.....
    from old_tablename
    Last edited by tlael; 12-03-03 at 17:27.

  5. #5
    Join Date
    Feb 2002
    Posts
    58
    thanks tlael

    You know what I mean though. I have a 50 column table where sales for 2002 is the 5th col, and now I'm adding a field for 2003 sales and it would be nice if they are next to each other so I don't have to scroll back and forth between them. I guess I'm just being over obsessive

  6. #6
    Join Date
    Oct 2003
    Location
    St.Louis,MO
    Posts
    120
    It really would be easier and less dangerous to just say...

    select column5, column51 ...
    from tablename

    and just order you columns in the select statement.
    Just a thought!!!
    Sometimes I like to do things the difficult way too.
    I makes me look like I am working harder than I really am!

  7. #7
    Join Date
    Jul 2003
    Posts
    2,296
    there's something to be said for having the PK columns at the beginning of the default column-order.

    We have the base-primarykey passed down through many tables and I personally like every tables PK that is based on those columns have the same order.

    This way it is easy for the developers to write code based on the PKs.
    It sounds dumb, but trust me, if you can help the developers match tables it will save you a lot of time later.

    Besides, most of my developers use TOAD (cause it's free) and TOAD uses the default column order.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  8. #8
    Join Date
    Oct 2003
    Location
    St.Louis,MO
    Posts
    120
    Good point Duck,
    I just get so used to creating tables in a manner that PK's are always the first columns and I only have to deal with "my" tables.
    Sometimes I look past the fact that people deal with other people's mistakes.
    Oh, and don't get me going on pleasing Developers!
    Baahhhhhhhh!

Posting Permissions

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