如何在已经安装好的PostgreSQL14中安装uuid 扩展

当前环境

             PG14.8 +LINUX 8.8

存在问题:

           开发人员问,PG中,支持 生成UUID吗,具体是什么,答,类似这个函数  uuid_generate_v4()
           看了一下, select uuid_generate_v4();会报错,找不到该函数
           原来postgresql 14 默认是没有该功能,但是可以通过扩展uuid-ossp来实现
 

解决办法


   由于PG是通过源码安装的,
   源码中已经有这个源码包了,不需要到处去找
  位置在:
  /postgresql/soft/postgresql-14.8/contrib/uuid-ossp

  1.检查是否已安装扩展uuid-ossp

      postgres=# \dx
                 List of installed extensions
          Name   | Version |   Schema   |         Description         
        ---------+---------+------------+------------------------------
        plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
        (1 row)

           可以看到postgresql目前没有安装uuid-ossp扩展。
 

   2.检查是否有可用安装的扩展UUID-OSSP

      --查看当前可用的扩展

postgres=# select * from pg_available_extensions;

        name        | default_version | installed_version |                                comment                                 

--------------------+-----------------+-------------------+------------------------------------------------------------------------

plpgsql            | 1.0             | 1.0               | PL/pgSQL procedural language

plperl             | 1.0             |                   | PL/Perl procedural language

plperlu            | 1.0             |                   | PL/PerlU untrusted procedural language

plpython2u         | 1.0             |                   | PL/Python2U untrusted procedural language

plpythonu          | 1.0             |                   | PL/PythonU untrusted procedural language

adminpack          | 2.1             |                   | administrative functions for PostgreSQL

amcheck            | 1.3             |                   | functions for verifying relation integrity

bloom              | 1.0             |                   | bloom access method - signature file based index

btree_gin          | 1.3             |                   | support for indexing common datatypes in GIN

btree_gist         | 1.6             |                   | support for indexing common datatypes in GiST

citext             | 1.6             |                   | data type for case-insensitive character strings

cube               | 1.5             |                   | data type for multidimensional cubes

dblink             | 1.2             |                   | connect to other PostgreSQL databases from within a database

dict_int           | 1.0             |                   | text search dictionary template for integers

dict_xsyn          | 1.0             |                   | text search dictionary template for extended synonym processing

earthdistance      | 1.1             |                   | calculate great-circle distances on the surface of the Earth

file_fdw           | 1.0             |                   | foreign-data wrapper for flat file access

fuzzystrmatch      | 1.1             |                   | determine similarities and distance between strings

hstore             | 1.8             |                   | data type for storing sets of (key, value) pairs

intagg             | 1.1             |                   | integer aggregator and enumerator (obsolete)

intarray           | 1.5             |                   | functions, operators, and index support for 1-D arrays of integers

isn                | 1.2             |                   | data types for international product numbering standards

lo                 | 1.1             |                   | Large Object maintenance

ltree              | 1.2             |                   | data type for hierarchical tree-like structures

old_snapshot       | 1.0             |                   | utilities in support of old_snapshot_threshold

pageinspect        | 1.9             |                   | inspect the contents of database pages at a low level

pg_buffercache     | 1.3             |                   | examine the shared buffer cache

pg_freespacemap    | 1.2             |                   | examine the free space map (FSM)

seg                | 1.4             |                   | data type for representing line segments or floating-point intervals

pg_prewarm         | 1.2             |                   | prewarm relation data

pg_stat_statements | 1.9             |                   | track planning and execution statistics of all SQL statements executed

pg_surgery         | 1.0             |                   | extension to perform surgery on a damaged relation

pg_trgm            | 1.6             |                   | text similarity measurement and index searching based on trigrams

pgcrypto           | 1.3             |                   | cryptographic functions

pgrowlocks         | 1.2             |                   | show row-level locking information

pgstattuple        | 1.5             |                   | show tuple-level statistics

pg_visibility      | 1.2             |                   | examine the visibility map (VM) and page-level visibility info

postgres_fdw       | 1.1             |                   | foreign-data wrapper for remote PostgreSQL servers

autoinc            | 1.0             |                   | functions for autoincrementing fields

insert_username    | 1.0             |                   | functions for tracking who changed a table

moddatetime        | 1.0             |                   | functions for tracking last modification time

refint             | 1.0             |                   | functions for implementing referential integrity (obsolete)

tablefunc          | 1.0             |                   | functions that manipulate whole tables, including crosstab

tcn                | 1.0             |                   | Triggered change notifications

tsm_system_rows    | 1.0             |                   | TABLESAMPLE method which accepts number of rows as a limit

tsm_system_time    | 1.0             |                   | TABLESAMPLE method which accepts time in milliseconds as a limit

unaccent           | 1.1             |                   | text search dictionary that removes accents

sslinfo            | 1.2             |                   | information about SSL certificates

xml2               | 1.1             |                   | XPath querying and XSLT

bool_plperlu       | 1.0             |                   | transform between bool and plperlu

bool_plperl        | 1.0             |                   | transform between bool and plperl

hstore_plperl      | 1.0             |                   | transform between hstore and plperl

hstore_plperlu     | 1.0             |                   | transform between hstore and plperlu

jsonb_plperlu      | 1.0             |                   | transform between jsonb and plperlu

jsonb_plperl       | 1.0             |                   | transform between jsonb and plperl

hstore_plpythonu   | 1.0             |                   | transform between hstore and plpythonu

hstore_plpython2u  | 1.0             |                   | transform between hstore and plpython2u

hstore_plpython3u  | 1.0             |                   | transform between hstore and plpython3u

jsonb_plpythonu    | 1.0             |                   | transform between jsonb and plpythonu

jsonb_plpython2u   | 1.0             |                   | transform between jsonb and plpython2u

jsonb_plpython3u   | 1.0             |                   | transform between jsonb and plpython3u

ltree_plpythonu    | 1.0             |                   | transform between ltree and plpythonu

ltree_plpython2u   | 1.0             |                   | transform between ltree and plpython2u

ltree_plpython3u   | 1.0             |                   | transform between ltree and plpython3u

(64 rows)


可以看到postgres目前并没有可用的uuid-ossp扩展。
此时,直接创建uuid-ossp会报错,如:

postgres=# create extension "uuid-ossp";
ERROR:  could not open extension control file "/postgres/pg14/share/extension/uuid-ossp.control": No such file or directory
postgres=#

注意:
要用双引号将uuid-ossp引起来,因为有个中划线“-”。
 

3.PG安装UUID选项



注意:以ROOT用户去编译

su - root

cd /postgresql/soft/postgresql-14.8/
./configure --prefix=/postgresql/pg14 --with-uuid=ossp   #prefix 安装目录

该操作只是在已安装完PG后,把uuid-ossp编译安装进了PG,不影响现有库。

 

4.源码编译UUID 


#进入扩展目录
# cd  /postgresql/soft/postgresql-14.8/contrib/uuid-ossp

#编译安装
# make && make install
 

5.配置UUID的软链接



--这里需要创建软连接,否则,后面创建扩展,会报错 :找不到 /postgresql/pg14/lib/libuuid.so.16

#  find / -name libuuid.so.16

/postgresql/soft/uuid/uuid-1.6.2/.libs/libuuid.so.16

# ln -s /postgresql/soft/uuid/uuid-1.6.2/.libs/libuuid.so.16 /postgresql/pg14/lib/

 

6.创建扩展



查看可用扩展
postgres=# select * from pg_available_extensions;
...
uuid-ossp          | 1.1             |                   | generate universally unique identifiers

可以看到已经有扩展uuid-ossp了。下面可以创建了。


创建扩展
postgres=# create extension "uuid-ossp";
CREATE EXTENSION
 

7.使用UUID


安装扩展成功以后,就可以使用函数uuid_generate_v4()来生产uuid了。

postgres=# select uuid_generate_v4();
           uuid_generate_v4           
--------------------------------------
9ef673d2-3652-455c-8b6e-c634165f514b

(1 row)
 

可以看到,已经安装好了

-------------------------------------------

为了方便交流,我建立了一个微信群:水煮数据库,主要交流日常运维中用到的数据库相关问题,包含但不限于:ORACLE,PG,MYSQL,SQLSERVER,OB,TIDB,达梦,TDSQL,OPENGAUSS,人大金仓,GBASE等等,如果有兴趣交流,可以加我微信:zq24803366, 我可以拉你入群。
————————————————

                            版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
                        
原文链接:https://blog.csdn.net/cqsztech/article/details/138426614

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/3016795.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

2024.4.29 Pandas day01 基础语法

pandas是python的一个数据库,在使用数据库的时候需要输入 import pandas as pd 引入, df pd.read.csv(文件路径“):这是利用pandas数据库读取CSV文件的方法,如果读取EXCEL文件或者其他文件,csv文件换成其他…

高项第四版 十大管理及49个过程【背】作业分享

项目管理 1.十大管理【背】 包括(口诀:范进整狗子(沟质) 才(采)干成疯子(风资)): (1)项目整合管理:识别、定义、组合、统一和协调各项目管理过程组的各个过…

STM32F10x移植FreeRTOS

一、获取FreeRTOS源码 (1)登录FreeRTOS官网:www.freertos.org,下载第一个压缩包 (2)通过GitHub网站:github.com/FreeRTOS/FreeRTOS下载,由于该网站服务器在国外,所以访问…

【busybox记录】【shell指令】sort

目录 内容来源: 【GUN】【sort】指令介绍 【busybox】【sort】指令介绍 【linux】【sort】指令介绍 使用示例: 排序 - 默认排序 排序 - 检查所给文件是否已经排序 排序 - 输出已经排序过的文件,不会重新排序 排序 - 忽略每行前面的空…

Linux cmake 初窥【2】

1.开发背景 基于上一篇的基础上,再次升级 2.开发需求 基于 cmake 指定源文件目录可以是多个文件夹,多层目录 3.开发环境 ubuntu 20.04 cmake-3.23.1 4.实现步骤 4.1 准备源码文件 工程目录如下 顶层脚本 compile.sh 负责执行 cmake 操作&#xff0…

基于51单片机的ADC0804的电压表设计(仿真+源码+设计资料)

目录 1、前言 2、资料内容 3、仿真图 4、程序 资料下载地址:基于51单片机的ADC0804的电压表设计(仿真源码设计资料) 1、前言 最近看网上有很少的ADC0804的设计了,都由0809代替,但是有个别因为成本原因和学校课…

从 Servlet 到 SpringMvc

从 Servlet 到 SpringMvc 下图为 SpringMvc 的 DispatcherServlet 到 Servlet 的继承体系结构,从 HttpServletBean 开始的子类,便属于 Spring 的体系结构,Spring 框架中类似这种以 XXXBean 结尾是用于和其它框架进行整合的 JavaBean 对象&am…

Unity技术学习:渲染大量物体的解决方案,外加RenderMesh、RenderMeshInstanced、RenderMeshIndirect的简单使用

叠甲:本人比较菜,如果哪里不对或者有认知不到的地方,欢迎锐评(不玻璃心)! 导师留了个任务,渲染大量的、移动的物体。 寻找解决方案: 当时找了几个解决方案: 静态批处…

硬件工程师必读:10条职业发展黄金法则!

在快速发展的科技时代,硬件工程师作为推动技术创新和产业升级的重要力量,其职业发展之路既充满挑战也蕴含无限机遇。为了在这条道路上稳步前行,我们首先需要了解硬件产品的研发流程。 在这个过程中,公司内的每个岗位都发挥着不可或…

【Linux】基础命令

常用命令及参数:dir表示文件夹,file表示文件(file可表示其他目录下的文件) pwd命令;查看当前所属文件夹(print working directory) ls [选项] dir;查看当前、指定文件夹目录内容&am…

6.移除元素

文章目录 题目简介题目解答解法一:双指针代码:复杂度分析: 解法二:双指针优化代码:复杂度分析: 题目链接 大家好,我是晓星航。今天为大家带来的是 相关的讲解!😀 题目简…

无卤素产品是什么?有什么作用?

无卤素产品,即在生产过程中完全不使用卤素元素——氟、氯、溴、碘等——的产品。 卤素元素,虽然在电子设备、材料等领域应用广泛,却也可能潜藏危害。其阻燃剂,一旦在产品生命周期结束后释放,将对土壤和水体造成污染&a…

pxe远程安装

PXE 规模化:可以同时装配多台服务器 自动化:自动安装操作系统和各种配置 不需要光盘U盘 前置需要一台PXE服务器 pxe是预启动执行环境,再操作系统之前运行 实验: 首先先关闭防火墙等操作 [rootlocalhost ~]# systemc…

普洱茶泡多少茶叶才算淡茶?

普洱茶淡茶一般放几克茶叶,品深茶官网根据多年专业研究与实践结果,制定了淡茶冲泡标准。在冲泡普洱茶淡茶时,茶叶的投放量是关键因素之一。淡茶冲泡标准旨在保持茶汤的清爽口感,同时充分展现普洱茶的独特风味。 根据《品深淡茶冲…

手动配置dns后网速变慢

之前因为自动的dns能上qq但打不开网页,就手动设置了一个,结果近些天时不时出现网页图片加载慢的问题,影响到我看美女图片了,是可忍熟不可忍 测了下网速,很快,下载上传都是三位数的,那显然不是网…

交易复盘-20240507

仅用于记录当天的市场情况,用于统计交易策略的适用情况,以便程序回测 短线核心:不参与任何级别的调整,采用龙空龙模式 一支股票 10%的时候可以操作, 90%的时间适合空仓等待 蔚蓝生物 (5)|[9:25]|[36187万]|4.86 百合花…

【Qt 学习笔记】Qt常用控件 | 输入类控件 | Date/Time Edit的使用及说明

博客主页:Duck Bro 博客主页系列专栏:Qt 专栏关注博主,后期持续更新系列文章如果有错误感谢请大家批评指出,及时修改感谢大家点赞👍收藏⭐评论✍ Qt常用控件 | 输入类控件 | Spin Box的使用及说明 文章编号&#xff1…

Quora 首席执行官亚当·德安杰洛 (Adam D’Angelo) 谈论了 AI、聊天机器人平台 Poe,以及 OpenAI 为什么不是竞争对手

每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗?订阅我们的简报,深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同,从行业内部的深度分析和实用指南中受益。不要错过这个机会,成为AI领…

回归预测 | Matlab实现基于CNN-SE-Attention-ITCN多特征输入回归组合预测算法

回归预测 | Matlab实现基于CNN-SE-Attention-ITCN多特征输入回归组合预测算法 目录 回归预测 | Matlab实现基于CNN-SE-Attention-ITCN多特征输入回归组合预测算法预测效果基本介绍程序设计参考资料 预测效果 基本介绍 【模型简介】CNN-SE_Attention结合了卷积神经网络&#xff…

代码随想录day19day20打卡

二叉树 1 二叉树的最大深度和最小深度 最大深度已经学习过了,实质就是递归的去判断左右子节点的深度,然后对其进行返回。 附加两个学习的部分: (1)使用前序遍历的方法求解 int result; void getdepth(TreeNode* nod…