通过SQL脚本在H2数据库中插入长文本 [英] Inserting a long text in H2 Database from an SQL script

查看:469
本文介绍了通过SQL脚本在H2数据库中插入长文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用H2的runscript运行sql脚本.

I'm trying to run a sql script using H2's runscript.

其中一个表包含一个长文本类型,该类型存储了一个xml文档(来自SAP数据库)

One of the table contains a longtext type which stores an xml document (from an SAP database)

因此,Insert语句包含XML的长文本(大约200行XML),虽然很难看,但仍然可以使用.

So the Insert statement contains the long text of the XML (about 200 lines of XML), which is rather ugly but still expected to work.

H2在SQL解析期间因ArrayOutOfBoundException崩溃.

H2 crashes with an ArrayOutOfBoundException during SQL parsing.

  • 插入语句接受的长度是否有限制?
  • 在nsert中,我使用刻度(如mysql中使用的)来分隔value(xml)...这将使转义最小化.可能是问题的一部分(适用于其他短领域)

我宁愿在这里使用普通的runscript H2工具,也不愿编写Java程序,尽管我认为它会更干净(可以使用Steam方法)

I would prefer using the plain runscript H2 tool here rather than make a Java program although I see it would be cleaner (could use the steam methods)

有见识吗?

推荐答案

没关系

通过使用适当的定界符(对于列名使用",对于值使用')并正确地将值中的引号转义(将其加倍)来使其工作

Got it working by using the proper delimiters (" for column names and ' for values) and escaping quotes in values properly (doubling it)

这篇关于通过SQL脚本在H2数据库中插入长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆