Alter SQL表-允许NULL列值 [英] Alter SQL table - allow NULL column value

查看:1407
本文介绍了Alter SQL表-允许NULL列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初,表"MyTable"的定义如下:

Initially, the table "MyTable" has been defined in the following way:

CREATE TABLE IF NOT EXISTS `MyTable` (
  `Col1` smallint(6) NOT NULL AUTO_INCREMENT,
  `Col2` smallint(6) DEFAULT NULL,
  `Col3` varchar(20) NOT NULL,
);

如何以允许"Col 3"列为NULL的方式更新它?

How to update it in such a way that the column "Col 3" would be allowed to be NULL?

推荐答案

以下MySQL语句应修改您的列以接受NULL.

The following MySQL statement should modify your column to accept NULLs.

ALTER TABLE `MyTable`
ALTER COLUMN `Col3` varchar(20) DEFAULT NULL

这篇关于Alter SQL表-允许NULL列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆