Change tinyint default value into 1 mysql
Asked Answered
C

5

13

I have a status column in my database table. Type : tinyint(4) and the Default value is 0. I want to change the default value to 1. How to do that? May be this is a very simple question, but I don't know.

Chaparro answered 4/4, 2014 at 9:32 Comment(0)
H
29

You can do so

ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL; 
Haehaecceity answered 4/4, 2014 at 9:36 Comment(2)
I've explained above.Licorice
Looks like in phpMyAdmin there is not this possiblityGregoor
M
8
ALTER TABLE MyTable MODIFY COLUMN col TINYINT NOT NULL DEFAULT 1;
Mourning answered 4/4, 2014 at 9:39 Comment(0)
R
2

Try this

ALTER TABLE `Type` CHANGE `status` `status` tinyint(4) NOT NULL DEFAULT 1
Refractometer answered 4/4, 2014 at 9:36 Comment(1)
why is '1' in quotes ?Yellowlegs
P
1
ALTER TABLE `your_table` CHANGE `your_column` `your_column` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '1'
Perez answered 4/4, 2014 at 9:37 Comment(1)
why '1' in quotes?Yellowlegs
V
1

If you want add any column in your table you can do this:

ALTER TABLE table_name CHANGE Column_name  tinyint(1) DEFAULT 1 NOT NULL;
Variole answered 16/5, 2018 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.