CREATE OR REPLACE FUNCTION tabledef(text,text) RETURNS text LANGUAGE sql STRICT AS $$ WITH attrdef AS ( SELECT n.nspname, c.relname, c.oid, pg_catalog.array_to_string(c.reloptions || array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ') as relopts, c.re...
array_cat(anyarray, anyarray) 连接两个数组,返回新数组 示例:array_cat(ARRAY[1, 2], ARRAY[3, 4]) 结果:{1, 2, 3, 4} array_cat(ARRAY[[1, 2]], ARRAY[3, 4]) 结果:{{1, 2}, {3, 4}} array_cat(ARRAY[[1, 2]], ARRAY[[3, 4]]) 结果:{{1, 2}, {3, 4}} array_ndim...
其中int[]表示数组长度无限制,int[4]表示数组长度为4. test=#createtabletbl_array(aint[],bvarchar(32)[][],cint);CREATETABLEtest=#insertintotbl_array (a,b,c)values(array[1,2],array[[1,2,3],[4,5,6]],1);INSERT01test=#insertintotbl_array (a,b,c)values(array[1,2,3],array[[1,...
ARRAY['os"dba', '123"456']); INSERT INTO test values(1, ARRAY['os''dba', '123''456']); // 多维数组,在向多维数组插入值时,各个维度的元素个数必须相同,否则会报错 INSERT INTO test values(1, ARRAY[['os', 'dba'],['dba', 'os']]); ...
CREATE TABLE AS 首先看看CREATE TABLE AS的用法,在这之前结合一个具体的例子看看,我们需要复制的是这样一张表: 如上图所示,在PowerDesigner的物理模型(pdm)中我们可以看到这张表定义了主键和一个外键,再看看它的ddl语句: drop table t_key_event_file_student; ...
array_to_string(spcacl, E'\n') AS "Access privileges(访问权限)" --,spcoptions AS "Options(参数)" ,pg_catalog.pg_size_pretty(pg_catalog.pg_tablespace_size(oid)) AS "Size(表空间大小)" --,pg_catalog.shobj_description(oid, 'pg_tablespace') AS "Description(备注)" from pg_catalog.pg...
Table 9-8. SQL字符串函数和操作符 还有额外的串操作函数可以用,它们在Table 9-9中列出。它们有些在内部用于实现Table 9-8列出的SQL标准字符串函数。 Table 9-9. 其他字符串函数 concat、concat_ws和format函数是可变的,因此可以把要串接或格式化的值作为一个标记了VARIADIC关键字的数组进行传递(见Section 36.4...
array_to_json row_to_json json_build_array 以及 jsonb_build_array json_object 以及 jsonb_object 查询JSON 字段数据 JSON 字段的查询和普通字段没有什么区别,例如: SELECT id, product_name, attributes FROM product; id|product_name|attributes | --+---+---+ 1|椅子 |{"color": "棕色", "hei...
CREATE TABLE sal_emp(name text,pay_by_quarter integer[],schedule text[][]); pay_by_quarter 为一维整型数组、schedule 为二维文本类型数组。 我们也可以使用 "ARRAY" 关键字,如下所示: CREATE TABLE sal_emp(name text,pay_by_quarter integer ARRAY[4],schedule text[][]); ...
在arrayt表的intarray数组类型列上创建一个GIN索引。 CREATE INDEX arrayt_idx ON arrayt USING gin(intarray); GiST索引 在customer表的c_comment列上创建一个GiST索引支持全文搜索。 CREATE INDEX customer_idx ON customer USING gist(to_tsvector('english', c_comment)); 重建索引 您可以使用REINDEX INDEX...