?
Solved

Change a boolean column to default False

Posted on 2011-02-20
7
Medium Priority
?
664 Views
Last Modified: 2012-05-11
To add a boolean column with the default value "False" works:
 
ALTER TABLE `platsonline`.`attribut_lists` 
   ADD COLUMN `B_TEST3` BOOLEAN DEFAULT TRUE NULL

Open in new window


But to change it when its already created?
0
Comment
Question by:Sunsales
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 34937846
BOOLEAN fields are synonomous with tinyint(1).  Just set it to 0 or 1.
0
 

Author Comment

by:Sunsales
ID: 34937862
I seen all these examples, when i run them in MysqlYog they dont work. I need working code.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 34938187
UPDATE platsonline SET B_Test3=0

will set the field to FALSE.



UPDATE platsonline SET B_Test3=1

will set the field to TRUE.
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 34938191
(Don't forget to add a WHERE clause to set just one row, otherwise these mysql statements will set every row in the table)
0
 

Author Comment

by:Sunsales
ID: 34938218
Thanx, but that wont do. I want the default value to be automatic set to False.
0
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 1000 total points
ID: 34938567
oh, sorry, didn't understand your question.

ALTER TABLE `platsonline`.`attribut_lists`
   MODIFY COLUMN `B_TEST3` BOOLEAN DEFAULT FALSE
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question