将NDJSON文件导入到SQL表

时间:2018-10-22 22:30:19

标签: javascript sql json database ndjson

是否有任何SQL命令导入ndjson文件?

例如:text.ndjson

{"id":10,"title":"harrypotter","ts":"2001-09-27 11:00:20.000000"}
{"id":6,"title":"arrow","ts":"2001-09-25 21:00:20.000000"}

我希望将其插入到SQL表中,以便它看起来像这样

id | ndjsonvalue
1  | {"id":10,"title":"harrypotter","ts":"2001-09-27 11:00:20.000000"}
2  | {"id":6,"title":"arrow","ts":"2001-09-25 21:00:20.000000"}

是否有任何SQL命令可以执行此操作?

我知道这是一个普通的json文件,文件看起来像这样

[{}, {}]

我可以打电话

`INSERT INTO ${tableName} (jsonCol) VALUES (NEW JSON('${jsonFileData}'));`;

0 个答案:

没有答案