ITPub博客

首页 > 数据库 > 国内数据库 > GBase8s BLOB类型使用操作示例

GBase8s BLOB类型使用操作示例

国内数据库 作者:朴所罗门 时间:2020-10-12 09:04:41 0 删除 编辑

1、  创建表结构:

create table "gbasedbt".tab1

  (

      col1 integer,

      col2 "gbasedbt".blob

  )   extent size 16 next size 64 lock mode row;

 

2  、  创建本地blobtest.png(该png文件为屏幕截图)

3  、使用filetoblob函数将blob数据插入数据库

1  )server端blob数据文件插入本地数据库

[gbasedbt@test2 ~]$ dbaccess dbutf8 -

数据库已被选用。

> insert into tab1 values   (1,filetoblob('/home/gbasedbt/blobtest.png','server'));

1  行被插入。

 

 

 

 

 

2  )客户端blob数据文件插入数据库:

 

4  、查询blob数据

    如下图示例,使用客户端工具查询blob数据  :

5  、使用lotofile函数复制大对象数据到文件

> ^C[gbasedbt@test2 ~]$ dbaccess   dbutf8 -

数据库已被选用。

> select   lotofile(col2,'/home/gbasedbt/blobtest2.png','server') from tab1  where col1 = 1;

(expression)  /home/gbasedbt/blobtest2.png.000000005d6f9d9c  

查询到 1  行。

 

[gbasedbt@test2 ~]$ ls -rlt   blobtest2.png.000000005d6f9d9c

-rw-rw-rw-. 1 gbasedbt gbasedbt 147571 7  月  21 05:12 blobtest2.png.000000005d6f9d9c

6  、使用locopy函数复制大对象数据到另一个大对象列中

[gbasedbt@test2 ~]$ dbaccess dbutf8 -

数据库已被选用。

> create table tab2(col3 int,col4   blob);

表已建妥。

 

> insert into tab2 values   (1,filetoblob('/home/gbasedbt/blobtest.png','server'));

1  行被插入。

 

> update tab2(col4) set col4=(select   locopy(col2) from tab1 where tab1.col1=1) where tab2.col3=1;

1  行被更新。

 


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69978212/viewspace-2726209/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-07-01

  • 博文量
    49
  • 访问量
    63234