[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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