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.
我的数据库表中有一个状态列。键入:tinyint(4),默认值为0.我想将默认值更改为1.如何做?可能这是一个非常简单的问题,但我不知道。
5 个解决方案
#1
10
You can do so
你可以这样做
ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL;
#2
5
ALTER TABLE MyTable MODIFY COLUMN col TINYINT NOT NULL DEFAULT 1;
#3
1
Try this
ALTER TABLE `Type` CHANGE `status` `status` tinyint(4) NOT NULL DEFAULT '1'
#4
1
ALTER TABLE `your_table` CHANGE `your_column` `your_column` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '1'
#5
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;
#1
10
You can do so
你可以这样做
ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL;
#2
5
ALTER TABLE MyTable MODIFY COLUMN col TINYINT NOT NULL DEFAULT 1;
#3
1
Try this
ALTER TABLE `Type` CHANGE `status` `status` tinyint(4) NOT NULL DEFAULT '1'
#4
1
ALTER TABLE `your_table` CHANGE `your_column` `your_column` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '1'
#5
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;