Search code examples
sqlt-sqlsybasesap-ase

Drop columns in Sybase ASE table


How can I drop a column in a Sybase ASE 15 table setup.

I have tried a few, to no avail:

alter table my_table
drop column1, column2

As well as looking at the Sybase documentation which provides no solution to my issues.

The 'select into' database option is not enabled for database 'my_db'. ALTER TABLE with data copy cannot be done. Set the 'select into' database option and re-run.


Solution

  • As your select into option on database is off, there are two option either you ON the select into option using

    sp_dboption my_db, "select into", true
    

    OR

    The no datacopy parameter to the alter table drop column allows you to drop columns from a table without performing a data copy, and reduces the amount of time required for alter table drop column to run.

    SYBASE Documentation - Dropping Columns from a Table Without Performing a Data Copy

    ALTER TABLE my_table
    DROP column1, column2
    WITH no datacopy