9

I tried to set null to columns like following.

ALTER TABLE myschema.table ALTER COLUMN (test_id,type) SET NOT NULL;

But it returned syntax error like Syntax error at or near Line 3, Position 47

Are there any proper way to achieve this ?

If someone has opinion please let me know.

Thanks

Heisenberg
  • 4,787
  • 9
  • 47
  • 76
  • Does this answer your question? [Change column type and set not null](https://stackoverflow.com/questions/16197236/change-column-type-and-set-not-null) – Stalinko Jun 03 '21 at 06:13

2 Answers2

12

You can't provide a list of column in parentheses, you need to use multiple ALTER COLUMN options separated by a comma:

ALTER TABLE the_table
    ALTER COLUMN test_id set not null, 
    ALTER COLUMN type SET NOT NULL;
6

Try doing it separately for both the columns:

ALTER TABLE myschema.table ALTER COLUMN test_id SET NOT NULL;

ALTER TABLE myschema.table ALTER COLUMN type SET NOT NULL;
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
Ria Kalia
  • 61
  • 3