我正在尝试将JSON文件加载到我创建的PostgreSQL表中,但是我似乎不知道该怎么做。
每次我尝试使用似乎适合SQL表但不适用于PostgreSQL的东西。
这是我的桌子:
create table test_opening_hours(
id serial primary key,
info json
);
我所能做的就是手动将行插入表中,但是我的文件有200多个不同的值,所以我不能这样做。我很确定必须有一种方法可以做到,但是我找不到方法...
这是我到目前为止尝试过的:
COPY test_opening_hours(info)
FROM 'data.json' ;
或
declare @jsondata nvarchar(max)
set @jsondata = 'data.json'
insert into test_opening_hours (info)
select * from openjson (@jsondata)