oracle怎么导出clob数据,Oracle数据库导出大字段(CLOB)数据

导出CLOB的几个SQL语句:

1.导出含有大字段数据的M条记录

exp user/passwd statistics=none compress=n consistent=y file=/oradata/info/backup/exp_article.dmp log=/oradata/info/backup/exp_article.log tables=fsm_right_article query=/"where rownum/<=10/"

2. 导出指定记录记录

exp user/passwd statistics=none compress=n consistent=y file=/oradata/info/backup/exp_article.dmp log=/oradata/info/backup/exp_article.log tables=fsm_right_article query=/"where recordid=n/"

3。 先将表按主键字段排序,然后取第1行到第2400行的记录

exp user/passwd statistics=none compress=n file=/oradata/info/backup/article/article_$i.dmp log=/oradata/info/backup/article/article_$i.log consistent=y tables=fsm_right_article query=/"where articleid in /(select articleid from /(select rownum as r_n/, article/.articleid from /(select articleid from fsm_right_article order by articleid desc/) article where rownum /<= 2400/) where r_n /> 0/)/"

编写一个shell脚本,循环执行导出2400条记录的命令,导出表的全部记录

vi /oradata/info/backup/scrips/exp_article.sh

#!/bin/bash

export ORACLE_BASE=/oracle/app/oracle

export ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

export ORACLE_SID=info

export PATH=/oracle/app/oracle/product/10.2.0/db_1/bin:$PATH:$HOME/bin

count=220979

i=0

step=2400

while [ $i -le $count ]

do

exp user/passwd statistics=none compress=n file=/oradata/info/backup/article/article_$i.dmp log=/oradata/info/backup/article/article_$i.log consistent=y tables=fsm_right_article query=/"where articleid in /(select articleid from /(select rownum as r_n/, article/.articleid from /(select articleid from couser/.fsm_right_article order by articleid desc/) article where rownum /<= $i+$step/) where r_n /> $i/)/"

i=`expr $i + $step`

file=`expr $file + 1`

done

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你的数据库Oracle,那么你可以使用Oracle提供的`DBMS_LOB`包中的`CONVERTTOCLOB()`函数将CLOB数据转换为字符串,然后使用`LOWER()`函数将搜索关键字转换为小写字母进行匹配。下面是一个示例: ``` public class MyEntitySpecifications { public static Specification<MyEntity> clobDataContains(String keyword) { return (root, query, builder) -> { Expression<String> clobData = builder.function("DBMS_LOB.CONVERTTOCLOB", String.class, root.get("clobData")); return builder.like(builder.lower(clobData), "%" + keyword.toLowerCase() + "%"); }; } } ``` 在这个示例中,我们使用了`DBMS_LOB.CONVERTTOCLOB()`函数将CLOB数据转换为字符串,并使用`like()`方法进行模糊匹配。我们还将搜索关键字转换为小写字母,以便不区分大小写地进行匹配。 然后,我们可以在`MyEntityRepository`接口中定义一个名为`findAllByClobDataContaining()`的方法,该方法接受一个`String`类型的参数`keyword`,并使用`MyEntitySpecifications.clobDataContains()`方法创建一个`Specification`对象进行查询: ``` public interface MyEntityRepository extends JpaRepository<MyEntity, Long>, JpaSpecificationExecutor<MyEntity> { List<MyEntity> findAllByClobDataContaining(String keyword, Pageable pageable); } ``` 在这个方法中,我们使用了`findAll()`方法的分页版本,并将`Specification`对象作为参数传递给它。 最后,在调用该方法时,我们可以像下面这样传递搜索关键字和分页参数: ``` Pageable pageable = PageRequest.of(0, 10); List<MyEntity> result = myEntityRepository.findAllByClobDataContaining("keyword", pageable); ``` 这样就可以使用`Specification`实现CLOB数据的模糊查询了。需要注意的是,`DBMS_LOB.CONVERTTOCLOB()`函数的具体实现可能因Oracle版本而异,需要根据实际情况进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值