美文网首页
greenplum中增加uuid函数

greenplum中增加uuid函数

作者: Iamveryrich | 来源:发表于2017-12-07 17:53 被阅读0次

1, 在$GPHOME/ext/中创建命名为 python的文件夹

2,在Shell中执行扩展命令:

           createlang plpythonu -d xxxxx(dbname)

3,创建函数uuid1( 生成的UUID中包括-):

create or replace function public.uuid_python() returns varchar(36)

AS $$

            import uuid

            return uuid.uuid1()

$$ LANGUAGE plpythonu;

4,创建函数uuid(生成的UUID中不包括-):

CREATE OR REPLACE FUNCTION "public"."uuid"() RETURNS "pg_catalog"."varchar" AS $BODY$

DECLARE

   BEGIN RETURN REPLACE (

            public.uuid_python() :: VARCHAR, '-', '' ) ;

END ;

$BODY$ LANGUAGE 'plpgsql' VOLATILE;

相关文章

网友评论

      本文标题:greenplum中增加uuid函数

      本文链接:https://www.haomeiwen.com/subject/bcrjixtx.html