将 tinyint 默认值更改为 1 mysql

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22858924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:22:19  来源:igfitidea点击:

Change tinyint default value into 1 mysql

mysqldatabasetinyint

提问by Karuppiah RK

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。怎么做?可能这是一个非常简单的问题,但我不知道。

回答by M Khalid Junaid

You can do so

你可以这样做

ALTER TABLE `table_name` CHANGE `column_name` `column_name` TINYINT(4) DEFAULT 1 NOT NULL; 

回答by e-fisher

ALTER TABLE MyTable MODIFY COLUMN col TINYINT NOT NULL DEFAULT 1;

回答by Pankaj sharma

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;

回答by Sadikhasan

Try this

尝试这个

ALTER TABLE `Type` CHANGE `status` `status` tinyint(4) NOT NULL DEFAULT '1'

回答by MrCarrot

ALTER TABLE `your_table` CHANGE `your_column` `your_column` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '1'