diff --git "a/content/docs-lite/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" "b/content/docs-lite/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" index e1ba84ab5492023f09bde25e146dd14cbf231a0e..663054b2c17c75ad10665bf736478095cc8c0e3c 100644 --- "a/content/docs-lite/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" +++ "b/content/docs-lite/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" @@ -1,3 +1,5 @@ # shark-函数和操作符 - **[系统信息函数](shark-系统信息函数.md)** + +- **[系统信息函数](shark-常用函数.md)** diff --git "a/content/docs-lite/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" "b/content/docs-lite/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..349667e2f8580b5e6405ef73c16fbc7d6c53ab94 --- /dev/null +++ "b/content/docs-lite/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" @@ -0,0 +1,51 @@ +# shark-常用函数 + +本章节只包含shark插件新增的常用函数。 + +- rand() + + 描述:0.0到1.0之间的随机数。等价于random。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT rand(); + rand + ------------------- + 0.254671605769545 + (1 row) + ``` + +- rand(seed int) + + 描述:根据入参设置随机数种子,随后生成0.0到1.0之间的随机数。等价于setseed+random。种子的有效值范围为 [-2^63, 2^64 - 1]。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT rand(1); + rand + ------------------- + 0.0416303444653749 + (1 row) + ``` + +- day(timestamp) + + 描述:获取日期/时间值中天数的值。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT day(timestamp '2001-02-16 20:38:40'); + day + ----------- + 16 + (1 row) + ``` diff --git "a/content/docs-lite/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" "b/content/docs-lite/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" index d8801f6cfe7fc2dfecce28e61ba207cb12270e2b..9f70c07e8f7f2420526607a403dbff4816198c21 100644 --- "a/content/docs-lite/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" +++ "b/content/docs-lite/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" @@ -51,3 +51,254 @@ ``` select @@SPID; ``` + +## 对象信息函数 + +- object_id('[database_name.[schema_name]. | schema_name.]object_name' [, 'object_type']) + + 描述:返回数据库对象的oid。如果没有查询权限或者对象不存在则返回NULL。 + + 第二个参数object_type支持以下类型 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性名称说明
S系统表
U用户表
V视图
SO序列
Ccheck约束
DDEAULTA约束
FFOREIGN KEY约束
PK主键约束
UQUNIQUE约束
AF聚合函数
FN函数
P存储过程
TR触发器
+ + 返回值类型:int + + 示例: + + ``` + CREATE TABLE sys.students ( + id SERIAL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + age INT DEFAULT 0, + grade DECIMAL(5, 2) + ); + set search_path = 'sys'; + select object_id('students'); + object_id + ----------- + 16666 + (1 row) + + select object_id('sys.students', 'U'); + object_id + ----------- + 16666 + (1 row) + ``` + + +- objectproperty(oid, property) + + 描述:返回插件框架中对象的对应属性结果。对象类型不符合返回NULL。 + + property可选范围 + + 返回值类型:int + + **表1** property属性表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性名称对象类型说明
IsDefault任何对象返回0。
IsDefaultCnst任何对象是否为DEFAULT约束。1=True, 0=False
IsDeterministic函数返回0。
IsIndexed表、视图有索引的表或视图。1=True, 0=False
IsInlineFunction函数内联函数。1=True, 0=False
IsSysShipped任何对象sys框架下的对象。1=True, 0=False
IsPrimaryKey任何对象是否为PRIMARY KEY约束。1=True, 0=False
IsProcedure任何对象是否为存储过程。1=True, 0=False
IsRule任何对象返回0。
IsScalarFunction函数是否为标量值函数。1=True, 0=False
IsSchemaBound函数、视图返回0。
IsTable是否为表。1=True, 0=False
IsTableFunction函数是否为表值函数。1=True, 0=False
IsTrigger任何对象是否为触发器。1=True, 0=False
IsUserTable是否为用户表。1=True, 0=False
IsView视图是否为视图。1=True, 0=False
OwnerId任何对象返回对象所有者的oid。
ExeclsQuotedIdentOn函数、存储过程、触发器、视图返回1。
ExeclsIsAnsiNullsOn函数、存储过程、触发器、视图返回1。
TableFulltextPopulateStatus返回0。
TableHasVarDecimalStorageFormat返回0。
+ + 示例: + 其中database为当前数据库 + + ``` + CREATE TABLE sys.students ( + id SERIAL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + age INT DEFAULT 0, + grade DECIMAL(5, 2) + ); + set search_path = 'sys'; + select objectproperty(object_id('students'), 'ownerid') as ownerid; + ownerid + --------- + 10 + (1 row) + select objectproperty(object_id('sys.students'), 'istable') as ownerid; + ownerid + --------- + 1 + (1 row) + select objectproperty(object_id('database.sys.students'), 'isview') as ownerid; + ownerid + --------- + 0 + (1 row) + ``` \ No newline at end of file diff --git "a/content/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" "b/content/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" index e1ba84ab5492023f09bde25e146dd14cbf231a0e..663054b2c17c75ad10665bf736478095cc8c0e3c 100644 --- "a/content/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" +++ "b/content/zh/docs/ExtensionReference/shark-\345\207\275\346\225\260\345\222\214\346\223\215\344\275\234\347\254\246.md" @@ -1,3 +1,5 @@ # shark-函数和操作符 - **[系统信息函数](shark-系统信息函数.md)** + +- **[系统信息函数](shark-常用函数.md)** diff --git "a/content/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" "b/content/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..349667e2f8580b5e6405ef73c16fbc7d6c53ab94 --- /dev/null +++ "b/content/zh/docs/ExtensionReference/shark-\345\270\270\347\224\250\345\207\275\346\225\260.md" @@ -0,0 +1,51 @@ +# shark-常用函数 + +本章节只包含shark插件新增的常用函数。 + +- rand() + + 描述:0.0到1.0之间的随机数。等价于random。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT rand(); + rand + ------------------- + 0.254671605769545 + (1 row) + ``` + +- rand(seed int) + + 描述:根据入参设置随机数种子,随后生成0.0到1.0之间的随机数。等价于setseed+random。种子的有效值范围为 [-2^63, 2^64 - 1]。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT rand(1); + rand + ------------------- + 0.0416303444653749 + (1 row) + ``` + +- day(timestamp) + + 描述:获取日期/时间值中天数的值。 + + 返回值类型:double precision + + 示例: + + ``` + openGauss=# SELECT day(timestamp '2001-02-16 20:38:40'); + day + ----------- + 16 + (1 row) + ``` diff --git "a/content/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" "b/content/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" index d8801f6cfe7fc2dfecce28e61ba207cb12270e2b..9f70c07e8f7f2420526607a403dbff4816198c21 100644 --- "a/content/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" +++ "b/content/zh/docs/ExtensionReference/shark-\347\263\273\347\273\237\344\277\241\346\201\257\345\207\275\346\225\260.md" @@ -51,3 +51,254 @@ ``` select @@SPID; ``` + +## 对象信息函数 + +- object_id('[database_name.[schema_name]. | schema_name.]object_name' [, 'object_type']) + + 描述:返回数据库对象的oid。如果没有查询权限或者对象不存在则返回NULL。 + + 第二个参数object_type支持以下类型 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性名称说明
S系统表
U用户表
V视图
SO序列
Ccheck约束
DDEAULTA约束
FFOREIGN KEY约束
PK主键约束
UQUNIQUE约束
AF聚合函数
FN函数
P存储过程
TR触发器
+ + 返回值类型:int + + 示例: + + ``` + CREATE TABLE sys.students ( + id SERIAL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + age INT DEFAULT 0, + grade DECIMAL(5, 2) + ); + set search_path = 'sys'; + select object_id('students'); + object_id + ----------- + 16666 + (1 row) + + select object_id('sys.students', 'U'); + object_id + ----------- + 16666 + (1 row) + ``` + + +- objectproperty(oid, property) + + 描述:返回插件框架中对象的对应属性结果。对象类型不符合返回NULL。 + + property可选范围 + + 返回值类型:int + + **表1** property属性表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
属性名称对象类型说明
IsDefault任何对象返回0。
IsDefaultCnst任何对象是否为DEFAULT约束。1=True, 0=False
IsDeterministic函数返回0。
IsIndexed表、视图有索引的表或视图。1=True, 0=False
IsInlineFunction函数内联函数。1=True, 0=False
IsSysShipped任何对象sys框架下的对象。1=True, 0=False
IsPrimaryKey任何对象是否为PRIMARY KEY约束。1=True, 0=False
IsProcedure任何对象是否为存储过程。1=True, 0=False
IsRule任何对象返回0。
IsScalarFunction函数是否为标量值函数。1=True, 0=False
IsSchemaBound函数、视图返回0。
IsTable是否为表。1=True, 0=False
IsTableFunction函数是否为表值函数。1=True, 0=False
IsTrigger任何对象是否为触发器。1=True, 0=False
IsUserTable是否为用户表。1=True, 0=False
IsView视图是否为视图。1=True, 0=False
OwnerId任何对象返回对象所有者的oid。
ExeclsQuotedIdentOn函数、存储过程、触发器、视图返回1。
ExeclsIsAnsiNullsOn函数、存储过程、触发器、视图返回1。
TableFulltextPopulateStatus返回0。
TableHasVarDecimalStorageFormat返回0。
+ + 示例: + 其中database为当前数据库 + + ``` + CREATE TABLE sys.students ( + id SERIAL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + age INT DEFAULT 0, + grade DECIMAL(5, 2) + ); + set search_path = 'sys'; + select objectproperty(object_id('students'), 'ownerid') as ownerid; + ownerid + --------- + 10 + (1 row) + select objectproperty(object_id('sys.students'), 'istable') as ownerid; + ownerid + --------- + 1 + (1 row) + select objectproperty(object_id('database.sys.students'), 'isview') as ownerid; + ownerid + --------- + 0 + (1 row) + ``` \ No newline at end of file