sql - 为什么插入语句在试图插入 json 的 postgres 中不起作用?
问题描述
为什么我的插入语句不起作用?
这是我的代码 http://sqlfiddle.com/#!17
create table json_check (
id serial primary key not null ,
body jsonb
)
insert into json_check (body)
values ('{
"test":"naveeb",
"data":"{'a':'ss'}"}')
它向我显示了一个语法错误。
解决方案
看来您的 JSON 无效。
insert into json_check (body)
values ('{
"test": "naveeb",
"data": {
"a": "ss"
}
}');
您可以在https://jsonlint.com/上检查您的 JSON 状态。
运行示例粘贴在以下链接:
推荐阅读
- php - PHPMailer不发送电子邮件(如果构造)
- python - tkinter Radiobutton:如何将多行文本与按钮对齐?
- neo4j - 使用 C#neo4j 客户端将关系属性添加到返回节点?
- scala - 如何执行单个嵌套的 ScalaTest Suite?
- python - 获取列表中可用的免费余额
- kubernetes - 在 kustomization.yaml 中排除资源
- twitter - 等待 Twitter 的 API 限制重置后再继续
- javascript - 如何计算输入栏的内容?- 反应JS
- vue.js - vue 3 使用 Vuex 和路由器的服务器端渲染
- java - 使用java从Array中过滤id值