1

对于以下 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);  
4

1 回答 1

4

你的dob价值观不正确。MySQL 的日期格式是yyyy-mm-dd. 最喜欢你得到默认0000-00-00存储和数据截断错误。

于 2012-10-22T17:40:22.977 回答