Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL : The name false is not permitted in this context

On executing the following SQL query

alter table tablename add columnname boolean not null default false;

I got the following error message:

The name "false" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

How should I fix this? Suggestions?

like image 952
Rahul Jain Avatar asked Feb 19 '23 22:02

Rahul Jain


2 Answers

The column type should be a bit field.

In SQL you use 0 and 1 to set a bit field. The values are displayed in SQL Server Management Studio as false or true, corresponding to 0 and 1.

alter table tablename add columnname bit not null default 0;
like image 115
Robert Avatar answered Feb 24 '23 09:02

Robert


There is no boolean data type. Use the bit data type.

The false value for a bit is 0.

alter table tablename add columnname bit not null default 0
like image 23
Guffa Avatar answered Feb 24 '23 08:02

Guffa