Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change tinyint default value into 1 mysql

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.

like image 422
Karuppiah RK Avatar asked Apr 04 '14 09:04

Karuppiah RK


People also ask

How do I set default value for Tinyint in MySQL?

Type : tinyint(4) and the Default value is 0.

How do I change the default value in MySQL?

To change a default value, use ALTER col_name SET DEFAULT : ALTER TABLE mytbl ALTER j SET DEFAULT 1000; Default values must be constants. For example, you cannot set the default for a date-valued column to NOW( ) , although that would be very useful.

How do I change my default value?

Set a default valueRight-click the control that you want to change, and then click Properties or press F4. Click the All tab in the property sheet, locate the Default Value property, and then enter your default value.

What does Tinyint 1 mean?

The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.


Video Answer


1 Answers

You can do so

ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL; 
like image 69
M Khalid Junaid Avatar answered Oct 06 '22 01:10

M Khalid Junaid