Columns Deletion

  • Hi

    I am currently having to delete some data from a table with six million rows.I need to delete columns 1,2,3,5, and 7 but leave the structure in forma ll tables and the data for columns 4,6,8,9,10.

    I#m updating the fields one by one this is taking a long time. Is there a quicker way to do this?

    Thanks.


    Kindest Regards,

    Nick

  • but leave the structure in forma ll tables and the data for columns 4,6,8,9,10.

    I am not quite sure what you are asking for. You can drop columns by using the alter table statement. Note that you must delete any constraints that exist on a column before dropping.

    ALTER TABLE MYTABLE

    DROP COLUMN TEST,

    TEST2,

    TEST3

  • Adam,

    Thanks for the reply. I need to keep the structure but set all the data in some columns to null whilst leaving the data in other columns


    Kindest Regards,

    Nick

  • Ah, so you just need to make the data in columns 1,2,3,5, and 7 null.

    UPDATE TABLENAME

    SET COL1 = NULL,

    COL2 = NULL,

    COL3 = NULL,

    COL5 = NULL,

    COL7 = NULL

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply