我正在尝试在创建为的客户表中实现 NOT NULL 约束:
CREATE TABLE CUSTOMER(
cust_id INT(5) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(cust_id),
first_name VARCHAR(25) NOT NULL,
last_name VARCHAR(25) NOT NULL,
email VARCHAR(25) NOT NULL,
password VARCHAR(25) NOT NULL,
gender VARCHAR(1) NOT NULL,
city VARCHAR(25) NOT NULL,
dob DATE NOT NULL,
pin INT NOT NULL);
在此之后,我将传递值并将其插入为:
$sql= "INSERT INTO customer(first_name,last_name,email,password,gender,city,dob,pin) VALUES('$first_name','$last_name','$email_add','$password','$gender','$city','$DOB','$pin')";
但是,如果我传递字段的空白值,Mysql 似乎会插入它们?可能是什么问题?