小编典典

列不能为空Mysql

sql

下面是我的表结构

CREATE TABLE IF NOT EXISTS `physicians` (
  `physician_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `physician_gender` varchar(10) NOT NULL,
  `physician_dob_date` int(11) NOT NULL,
  `physician_dob_month` int(11) NOT NULL,
  `physician_dob_year` year(4) NOT NULL,
  `physician_profession` varchar(50) NOT NULL,
  `medical_specialty` varchar(100) NOT NULL,
  `medical_school` varchar(100) NOT NULL,
  `traning_year` year(4) NOT NULL,
  `physician_minc` varchar(20) NOT NULL,
  `physician_country` varchar(100) NOT NULL,
  `physician_state` varchar(60) NOT NULL,
  `physician_city` varchar(60) NOT NULL,
  `physician_address` varchar(100) NOT NULL,
  `physician_postal_code` varchar(10) NOT NULL,
  `physician_phone_number` varchar(20) NOT NULL,
  `physician_default_msg` longtext NOT NULL,
  PRIMARY KEY (`physician_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

我正在执行查询,它向我显示列不能为空,这是我的查询

INSERT INTO `physicians` (`user_id`, `physician_gender`, `physician_dob_date`, `physician_dob_month`, `physician_dob_year`, `physician_profession`, `medical_specialty`, `medical_school`, `traning_year`, `physician_minc`, `physician_country`, `physician_state`, `physician_city`, `physician_address`, `physician_postal_code`, `physician_phone_number`, `physician_default_msg`) VALUES (4, 'Female', '5', '7', '1955', '3', '2', '1', '1965', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

错误-列’physician_minc’不能为空

physician_minc不是必填字段。我该如何解决这个问题?


阅读 362

收藏
2021-03-10

共1个答案

小编典典

您已将not null值定义为’physician_minc’:

`physician_minc` varchar(20) NOT NULL,

如何将null值传递给它。首先,您需要将physician_minc列设置为null,然后才可以传递所需的null值。

`physician_minc` varchar(20) NULL,
2021-03-10