[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 676
  • Last Modified:

Change a boolean column to default False

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
Paer Toernell
Asked:
Paer Toernell
  • 5
  • 2
1 Solution
 
Cornelia YoderArtistCommented:
BOOLEAN fields are synonomous with tinyint(1).  Just set it to 0 or 1.
0
 
Paer ToernellAuthor Commented:
I seen all these examples, when i run them in MysqlYog they dont work. I need working code.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
Cornelia YoderArtistCommented:
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
 
Cornelia YoderArtistCommented:
(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
 
Paer ToernellAuthor Commented:
Thanx, but that wont do. I want the default value to be automatic set to False.
0
 
Cornelia YoderArtistCommented:
oh, sorry, didn't understand your question.

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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now