Santhosh
Santhosh

Reputation: 11774

postgresql: whats wrong in my sql statement of altering a column in a table

I am trying to alter a tables column with a default value of -11 and it can be null

ALTER TABLE devicedata ALTER COLUMN "weather" smallint NULL DEFAULT -11 ;

it says error

enter image description here

Upvotes: 0

Views: 55

Answers (1)

GMB
GMB

Reputation: 222432

In Postgres the syntax for this is:

alter table device_data alter column wheather type smallint;

Then you can change the default:

alter table device_data alter column wheather set default 10;

The column keyword is optional.

Upvotes: 1

Related Questions