array_cat()
是一个用于连接两个数组的系统函数。
array_cat()
在 PostgreSQL 7.4 中被添加。
示例
array_cat()
的基本用法示例
postgres=# SELECT array_cat(array[1,2], array[3,4]); array_cat ----------- {1,2,3,4} (1 row) postgres=# SELECT array_cat(array['foo','bar'], array['baz','boo']); array_cat ------------------- {foo,bar,baz,boo} (1 row)
请注意,anyarray
||
anyarray
操作符是等价的。
postgres=# SELECT array[1,2] || array[3,4]; ?column? ----------- {1,2,3,4} (1 row)
无法连接不同数据类型的数组。
postgres=# SELECT array_cat(array['foo','bar'], array[3, 4]); ERROR: function array_cat(text[], integer[]) does not exist LINE 1: SELECT array_cat(array['foo','bar'], array[3, 4]); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
参考资料
- PostgreSQL documentation: 数组函数
反馈
在此处 提交关于 "array_cat()
" 的任何评论、建议或更正。