skip to Main Content

enter image description here

an easy way to delete the b_color column?

2

Answers


  1. I depends on what you mean by delete a column.

    If you mean set all values to null in the column, then use update:

    update mytable set b_color = null;
    

    Disclaimer: original values are deleted for good. You might want to take a backup first.

    If you mean permanently remove that column from the table, then use drop column:

    alter table mytable drop column b_color;
    

    Use the latter with caution! This is a data definition statement: once the column is gone, it cannot be retrieved any more – you need to recreate it from scratch.

    Login or Signup to reply.
  2. You can use an alter table statement:

    ALTER TABLE mytable DROP COLUMN b_color
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search