I'm trying to add a column to a Hana sql table of blob data type, but my table already contains data and must not be null, which prevents me from adding the column. Does anyone know the correct structure.
I am doing it like this:
ALTER TABLE "CLIENTES"."DATOS" ADD ("IMAGEN" BLOB NOT NULL DEFAULT)
It is the one that gives me an error, can someone help me
This happens because the table already has rows. There are two paths.
ALTER TABLE "CLIENTES"."DATOS" ADD ("IMAGEN" BLOB NOT NULL NOVALIDATE )
ALTER TABLE "CLIENTES"."DATOS" ADD ("IMAGEN" BLOB)
, then assign a value to the data that the table already has, for this you use the UPDATE function with a SET in the IMAGE column, once all the fields already have a value other than NULL, add the not null constraint again for this column usingALTER TABLE | ALTER COLUMN
and add the constraint.Initialize with an empty BLOB: