Improve company productivity with a Business Account.Sign Up

x
?
Solved

Change a boolean column to default False

Posted on 2011-02-20
7
Medium Priority
?
683 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:Paer Toernell
  • 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:Paer Toernell
ID: 34937862
I seen all these examples, when i run them in MysqlYog they dont work. I need working code.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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:Paer Toernell
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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

589 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