【问题标题】:Change JSON hierarchy by SQL query in Oracle在 Oracle 中通过 SQL 查询更改 JSON 层次结构
【发布时间】:2021-01-21 12:26:39
【问题描述】:

我有一个包含 JSON 的带有 clob 的表。 JSON 已经存在,我需要更改第一个值的层次结构。

这是原始的json:

{
  "configurationByAssetType" :
  {
    "default" :
    {
      "sections" :
      [
....
]
}}}

我需要将 configurationByAssetType 放在新部分 - configurationByView 下:

{
"configurationByView"
{
 "default" :{
  "configurationByAssetType" :
  {
    "default" :
    {
      "sections" :
      [
....
]
}}}}}

我想复制所有现有数据到:

{
"configurationByView"
{
 "default" :{

【问题讨论】:

    标签: sql json database oracle clob


    【解决方案1】:

    为什么不将必要的字符连接到 clob 的开头和结尾:

    with q as
     (select to_clob('{  "configurationByAssetType" :
                    {
                      "default" :
                      {
                        "sections" :
                        [
                  ....
                  ]
                  }}}') clob_json
    from dual) 
    select '{
    "configurationByView"
        {
      "default" :{' || clob_json || '}}}'
      from q;
    

    【讨论】:

    • 谢谢!这正是我写完问题后的想法。
    猜你喜欢
    • 1970-01-01
    • 2020-04-17
    • 2015-10-15
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    相关资源
    最近更新 更多