Remove a column comment in Snowflake

Viewed 266

From Snowflake's documentation, it's clear how to add or overwrite a comment on a table column, but it doesn't look like you can remove a comment one without re-creating the table.

CREATE TABLE "My_Table" (
  "my_column" INT
);
ALTER TABLE "My_Table" ALTER "my_column" COMMENT 'New Comment';  -- Works
ALTER TABLE "My_Table" ALTER "my_column" COMMENT NULL; -- Fails
ALTER TABLE "My_Table" ALTER "my_column" COMMENT '';  -- Works, but prefer NULL

As shown above, the best I can find is to set the comment to '', but I would really prefer it to be null. Does anyone know how to remove a comment?

1 Answers

steps are:

  1. create a new column column2
  2. update the table so column2 = column1
  3. drop column1
  4. then rename column2 to column1;

Not sure if its worth the effort, but here goes:

alter table my_table add column my_column2 int;

update my_table set my_column2 = my_column;

alter table my_table drop column my_column;

alter table my_table rename column my_column2 to my_column;

describe table my_table ;

Validation of Script - Image

Related