sql - Amazon RedShift Drop Default -


i want add not null column table in redshift. this, specify default existing rows know put in new column. don't want default on column - if no data supplied in copy command, want fail. in postgres this:

alter table my_table alter column my_column drop default; 

however redshift gives me error saying error: alter column set/drop default not supported.

what correct way add non-null column, update existing rows, , not have default?

update: seems redshift won't allow alter column statements. make impossible?

you following:

  • create new table new schema (including not null)
  • insert new_table pseudo-default hard-coded
  • drop old table
  • rename new one

e.g

create table new_table  (column_1 type, column_2 type, new_column type not null);  insert new_table (column_1, column_2, new_column) select column_1, column_2, 'default_value' old_table;  drop table old_table; alter table new_table rename old_table; 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -