1

I have this simple table:

create table Customers
(
    Id bigint not null primary key auto_increment,
    Name varchar(100) not null,
    IsVip boolean null
)

Now I want to set a default value for IsVip column. I tried:

alter table Customers
modify IsVip set default 0

But it doesn't work. How should I do it?

0

1 Answer 1

3

According to the ALTER TABLE syntax you use the syntax

    | ALTER [COLUMN] col_name SET DEFAULT literal | (expression)

or the syntax

    | MODIFY [COLUMN] [IF EXISTS] col_name column_definition

In your case it can be

alter table Customers ALTER COLUMN IsVip set default 0
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I was using modify incorrectly. Thank you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.