Solved

Change a boolean column to default False

Posted on 2011-02-20
7
652 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:yodercm
ID: 34937846
BOOLEAN fields are synonomous with tinyint(1).  Just set it to 0 or 1.
0
 
LVL 27

Expert Comment

by:yodercm
ID: 34937850
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 27

Expert Comment

by:yodercm
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:yodercm
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:
yodercm earned 250 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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 …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 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