SQL Server

时间:2016-11-21 07:05:28

标签: sql arrays sql-server

PostgreSQL允许将表的列定义为可变长度的多维数组。像这样:

CREATE TABLE sal_emp 
(
    name            text,
    pay_by_quarter  integer[],
    schedule        text[][]
);

一些INSERT语句如下

INSERT INTO sal_emp
VALUES ('Bill', '{10000, 10000, 10000, 10000}',
        '{{"meeting", "lunch"}, {"training", "presentation"}}');

INSERT INTO sal_emp
VALUES ('Carol', '{20000, 25000, 25000, 25000}',
        '{{"breakfast", "consulting"}, {"meeting", "lunch"}}');

SELECT * FROM sal_emp;

输出:

 name  |      pay_by_quarter       |                 schedule
-------+---------------------------+-------------------------------------------
 Bill  | {10000,10000,10000,10000} | {{meeting,lunch},{training,presentation}}
 Carol | {20000,25000,25000,25000} | {{breakfast,consulting},{meeting,lunch}}
(2 rows)

我们如何在SQL Server中实现相同的功能或任何替代方案?

1 个答案:

答案 0 :(得分:0)

SQL Server中没有替代数组数据类型。