如何在oracle sql developer中导出clob字段数据

Pra*_*ran 12 oracle-sqldeveloper

如何在oracle sql developer中导出clob字段数据.目前clob字段数据无法在oracle sql开发人员中导出.

Ale*_*ole 11

如果您不想(或不能)导出和导入数据,并且真的希望它作为一组插入语句,您可以使用SQL Developer的内置格式化工具自动将CLOB分成多个块,这些块是小到足以作为字符串文字有效,然后将结果假脱机到一个文件:

spool clob_export.sql
select /*insert*/ * from your_table;
spool off
Run Code Online (Sandbox Code Playgroud)

使用更新的版本,您可以使用sqlformat命令来控制输出格式,而无需修改查询; 这相当于:

set sqlformat insert
spool clob_export.sql
select * from your_table;
spool off
Run Code Online (Sandbox Code Playgroud)

生成的insert语句如下所示:

REM INSERTING into YOUR_TABLE
SET DEFINE OFF;
Insert into YOUR_TABLE (ID,CLOB_COLUMN) values (1,TO_CLOB('... up to 4k of characters with quotes escaped ...')
|| TO_CLOB('... up to 4k of characters with quotes escaped ...')
|| TO_CLOB('... up to 4k of characters with quotes escaped ...')
...
|| TO_CLOB('... up to 4k of characters with quotes escaped ...'));
Run Code Online (Sandbox Code Playgroud)

  • 对于SQL Developer用户的重要信息:为了使其正常工作,您不能单独执行这些行。您需要将它们作为脚本执行。 (2认同)