- 论坛徽章:
- 0
|
postgreSQL中怎样建个带图片字段的表啊?
原帖由 "marszxy" 发表:
postgreSQL中怎样建个带图片字段的表啊?
是不是这样啊:
create table test(
id int4 not null,
name varchar(10) not null,
tupian BLOB,
primary key(id)
);
如不是那应该是怎么建啊?
BLOB在PG中没有。可以用三种方式存图片
1.使用大对象
create table test(
id int4 not null,
name varchar(10) not null,
tupian oid,
primary key(id)
);
2.使用Text字段将二进制图片用BASE64编码存为字符串
create table test(
id int4 not null,
name varchar(10) not null,
tupian text,
primary key(id)
);
3.用二进制数组bytea
create table test(
id int4 not null,
name varchar(10) not null,
tupian bytea,
primary key(id)
);
以上三种方式(第一种属过时的方法,且操作稍复杂)都可以存图片
或其它任何格式的数据长度好象是2G的限制。 |
|