小编Mic*_*syk的帖子

Postgres - 通过SQL插入varchar数组

我想执行此查询.

INSERT INTO items (title, description,
start_date,
expiration_date,
type,
quantity,
state,
sold,
cover_photo_file_name,
cover_photo_content_type,
cover_photo_file_size,
instructions)
VALUES
(
    'some_test_value',
    'lorem ipsum',
    '2015-01-01 00:00:00',
    '2015-06-10 00:00:00',
    0,
    19,
    0,
    0,
    'RackMultipart20150317-10093-1ny4gmx.gif',
    'image/gif',
    157574,
    {"lorem ipsum\r","dolor sit\r","loremloremipsumipsum 'sitsit' dolor sit"}
    );
Run Code Online (Sandbox Code Playgroud)

我觉得非常讨厌

ERROR: syntax error at or near "{"
Run Code Online (Sandbox Code Playgroud)

当我尝试这样做的时候

ARRAY["Lorem ipsum\r", ...]
Run Code Online (Sandbox Code Playgroud)

我明白了:

ERROR: column "Lorem ipsum" does not exist
Run Code Online (Sandbox Code Playgroud)

问题是我现在无法更改数据库(我没有时间)所以我需要构建一个将"执行"该工作的查询(尽管此数据库需要使用DROP DATABSE进行规范化...)

我的代码出了什么问题?也许我错过了一些明显的东西,但我疲惫的心灵只是在跳过它.

database arrays postgresql insert pg

2
推荐指数
2
解决办法
5494
查看次数

标签 统计

arrays ×1

database ×1

insert ×1

pg ×1

postgresql ×1