12

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.

Mamun
  • 66,969
  • 9
  • 47
  • 59
Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80

5 Answers5

29

You can do so

ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL; 
M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118
8
ALTER TABLE MyTable MODIFY COLUMN col TINYINT NOT NULL DEFAULT 1;
e-fisher
  • 659
  • 1
  • 6
  • 8
2

Try this

ALTER TABLE `Type` CHANGE `status` `status` tinyint(4) NOT NULL DEFAULT 1
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
1
ALTER TABLE `your_table` CHANGE `your_column` `your_column` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '1'
MrCarrot
  • 2,546
  • 1
  • 23
  • 29
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;
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103