【发布时间】:2014-01-07 09:10:51
【问题描述】:
我正在学习 mysql,并且在构建图像数据库的代码方面遇到了巨大的麻烦......
我知道如何创建表格,并且我知道我需要 longblob 来存储图像。不是问题。目前我正在通过以下方式创建:CREATE TABLE pics
(
picid int unsigned not null auto_increment primary key,
filename varchar(255) not null unique,
caption varchar(255) not null,
pic longblob not null
);
picid 中的“not null”给我带来了问题。因为接下来当我尝试使用此代码进行填充时:
INSERT INTO pics values
(
NULL,
'bear.jpg',
'a picture of a bear',
LOAD_FILE('C:/Users/USERS_NAME/Pictures/bear.jpg')
);
我遇到错误 #1048 - 列 'pic' 不能为空。
请帮忙。我快疯了……
【问题讨论】:
-
你为什么用sql-server 标记它...答案是你不应该将图像存储在数据库中。
-
建议使用 sql-server 标记...我正在学习老兄..有人建议我使用路径而不是仅将图片加载到数据库中