Column cannot be null Mysql

前端 未结 8 1749
广开言路
广开言路 2020-12-21 05:12

Below is my table structure

CREATE TABLE IF NOT EXISTS `physicians` (
  `physician_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
         


        
相关标签:
8条回答
  • 2020-12-21 05:55

    If you don't want to enter a value simply don't make the column not null, skip this statement, else it is compalsary to enter a value in it.

    0 讨论(0)
  • 2020-12-21 06:02

    When you create your table you define a columns as mandatory with NOT NULL. You should change all columns which are not mandatory to NULL instead.

    For your insert code I assume only the first 10 fields are mandatory so to correctly insert your data your table generating code should be as follows:

    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) NULL,
      `physician_country` varchar(100) NULL,
      `physician_state` varchar(60)  NULL,
      `physician_city` varchar(60) NULL,
      `physician_address` varchar(100)  NULL,
      `physician_postal_code` varchar(10)  NULL,
      `physician_phone_number` varchar(20)  NULL,
      `physician_default_msg` longtext  NULL,
      PRIMARY KEY (`physician_id`),
      KEY `user_id` (`user_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
    
    0 讨论(0)
提交回复
热议问题