Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PostGresql,在表中创建一个可以获取多个值的变量。_Sql_Postgresql_Variables - Fatal编程技术网

PostGresql,在表中创建一个可以获取多个值的变量。

PostGresql,在表中创建一个可以获取多个值的变量。,sql,postgresql,variables,Sql,Postgresql,Variables,我想用一个名为polygons的变量创建一个表,该变量可以取多个值。可能吗?以及如何向该表插入数据? 我正在试着做下面的事情,但我做不到。有什么线索吗 CREATE TABLE test1 ( id integer, year integer, polygons integer[] ); INSTER INTO test1 (id,year,polygons) Values (1,2015,[12,52,53]); 这是定义类型为值数组的列(而不是变量)的正确方法。但是

我想用一个名为polygons的变量创建一个表,该变量可以取多个值。可能吗?以及如何向该表插入数据? 我正在试着做下面的事情,但我做不到。有什么线索吗

CREATE TABLE test1 (
    id integer,
    year integer,
    polygons integer[]
);
INSTER INTO test1 (id,year,polygons)
Values (1,2015,[12,52,53]);

这是定义类型为值数组的列(而不是变量)的正确方法。但是,数组文字是一个字符串,其内容包含在
{}
中:

INSERT INTO test1 (id, year, polygons)
VALUES (1, 2015, '{12, 52, 53}')
你可以在网上阅读更多