Solved

Change a boolean column to default False

Posted on 2011-02-20
7
640 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now