Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Location
    Czech Republic
    Posts
    82

    Unanswered: Sybase 12.5 adding column before existing column

    Hello,

    is there any simple possibility how to add newcolumn to a large table before existing column(s)?

    DavidM

  2. #2
    Join Date
    Jun 2010
    Posts
    51
    Not possible by altering table. rename existing table and then create a new table with same definition as re-named table (including the column you want) and shift entire data to this new table. drop the original table.

    E.g.
    original table is b...rename it to a using sp_rename
    create table b with all the columns from table a and the new column.
    shift data from a to b
    drop table a

  3. #3
    Join Date
    Feb 2009
    Location
    Prague
    Posts
    17
    Wouldn't be simpler to create a view with columns in desired order?
    Anyway, I don't think there is a simple way how to do it (like alter table).

    I would rename the table (to i.e. TAB2) and then, for example, select (columns in correct order) into TAB1.

    (but be aware, that object id will change...)
    Last edited by jannovak; 08-25-10 at 06:42.

  4. #4
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    It doesn't really matter in which order your columns are, other than readability. You can display columns in ny order you want in a select-statement, or in a view.
    I'm not crazy, I'm an aeroplane!

Posting Permissions

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