sql 查询转换json

sqlserver:https://learn.microsoft.com/zh-cn/sql/relational-databases/json/how-for-json-converts-sql-server-data-types-to-json-data-types-sql-server?view=sql-server-ver16

--2016后使用 FOR JSON

select *from @sale for json auto 

  oracle:

1.参考:https://dgrt.cn/a/2558773.html?action=onClick

2.oracle 12c - Oracle 19C:参考 https://www.modb.pro/db/233455

  select JSON_OBJECT(*) from v$database;

{
    "DBID": 2241305521,
    "NAME": "ORCL",
    "CREATED": "2021-11-10T17:34:41",
    "PRIOR_RESETLOGS_TIME": null
}

SELECT JSON_OBJECT(
'log_mode' : name||' is '||log_mode||' mode;',
'force_logging' : force_logging,
'supplemental_log_data_min' : supplemental_log_data_min
)
FROM v$database;

{
    "log_mode": "BILL is ARCHIVELOG mode;",
    "force_logging": "YES",
    "supplemental_log_data_min": "YES"
}

  

 

posted @ 2023-07-25 10:12  流氓大菠萝  阅读(119)  评论(0编辑  收藏  举报