对于以下SQL,我收到错误:
写入列时发生数据截断0Data长度为0字节,传输了0个字节。
代码:
CREATE TABLE faculty_members
(
fid INTEGER AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(30) NOT NULL,
last_name VARCHAR(30) NOT NULL,
rank VARCHAR(25) NOT NULL,
office CHAR(8),
phone CHAR(12),
dob DATE NOT NULL,
salary DECIMAL(8,2),
CONSTRAINT faculty_members_pk PRIMARY KEY(fid),
CONSTRAINT faculty_members_ck UNIQUE(first_name,last_name,dob),
CONSTRAINT valid_salary CHECK(salary > 0)
);
这些是INSERT语句
INSERT INTO faculty_members(first_name,last_name,rank,office,phone,dob,salary) VALUES
('Charles', 'Xavier', 'Professor', 'HSC 641', '563-555-6020', '11/09/1942', 125000),
('Bruce', 'Banner', 'Associate Professor', 'FO1 120', '563-555-8212', '06/20/1969', 87000),
('Hank', 'McCoy', 'Professor', 'FO1 120', '563-555-8212', '06/20/1972', 95000),
('Jeane', 'Grey', 'Assistant Professor', 'ECS 547', '563-555-8239', '03/19/1975', 95000),
('Erik', 'Lehnsherr', 'Professor', 'HSC 641', '563-555-6020', '11/09/1940', 115000),
('Diana', 'Prince', 'Associate Professor', 'HSC 400', '563-555-8212', '07/28/1967', 105100),
('Logan', 'Wolverine', 'Assistant Professor', 'ECS 540', '563-555-8100', '02/27/1964', 82000),
('Ororo', 'Storm', 'Assistant Professor', 'ECS 540', '563-555-8101', '05/01/1973', 82500);
答案 0 :(得分:4)
您的dob
值不正确。 MySQL的日期格式为yyyy-mm-dd
。大多数人都希望您能够保存默认的0000-00-00
并从中获取数据截断错误。