如何在已经安装好的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://www.mfbz.cn/a/599839.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

2024-05-07 商业分析-如何在社会层面做一个更好的工具人-记录

摘要: 2024-05-07 商业分析-如何成为一个靠谱的工具人 如何在社会层面做一个更好的工具人 那么今天讲的这个主题呢,对吧?你们一看啊,就觉得这个就不应该我讲是吧啊,但是呢这个逻辑呢我还得跟你们讲一下啊,就是如何成为…

2009-2022年上市公司华证ESG评级评分数据(含细分项)

2009-2022年上市公司华证ESG评级评分数据(含细分项) 1、时间:2009-2022年 2、来源:华证ESG 3、指标:证券代码、证券简称、综合评级、年度、综合得分、E评级、E得分、S评级、S得分、G评级、G得分 4、范围&#xff1…

AI伦理和安全风险管理终极指南

人工智能(AI)正在迅速改变各个领域的软件开发和部署。驱动这一转变的两个关键群体为人工智能开发者和人工智能集成商。开发人员处于创建基础人工智能技术的最前沿,包括生成式人工智能(GenAI)模型、自然语言处理&#x…

Python读取ASC文件并转换成Excel文件(坐标)

import pandas as pd# 读取asc文件,指定空格为分隔符 df pd.read_csv(out_view2.asc, sep , headerNone)# 去掉空列 df df.dropna(howall, axis1)# 将数据保存到Excel文件 df.to_excel(out_view2.xlsx, indexFalse, headerFalse)效果图

Day1| Java基础 | 1 面向对象特性

Day1 | Java基础 | 1 面向对象特性 基础补充版Java中的开闭原则面向对象继承实现继承this和super关键字修饰符Object类和转型子父类初始化顺序 多态一个简单应用在构造方法中调用多态方法多态与向下转型 问题回答版面向对象面向对象的三大特性是什么?多态特性你是怎…

unity华为sdk接入指路指南

目前比较靠谱的几个方案:试过几个仅供参考 温馨提示:最高目前可支持方案到unity2021版本以下,以上请联系华为官方寻求技术支持 Unity集成华为游戏服务SDK方式(一):集成Unity官方游戏SDK: 华为…

代码随想录算法训练营第十八天:二叉树的层序遍历(中间放假)

代码随想录算法训练营第十八天:二叉树的层序遍历(中间放假) ‍ ​​ 102.二叉树的层序遍历 力扣题目链接(opens new window) 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右…

速览Coinbase 2024Q1 财报重点:业务全面开花,净利润达11.8亿美元

作者:范佳宝,Odaily 星球日报 近期,Coinbase 发布了其 2024 年第一季度财报。 报告显示,Coinbase 第一季度营收为 16.4 亿美元,高于分析师平均预期的 13.4 亿美元;净利润为 11.8 亿美元,合每股…

关于Centos 7/8 网络设置 与工具连接

网络三步曲的配置 1、首先更改虚拟机的网络配置 查看子网地址以及网关 如果有要求需要更改IP地址,规定第三位是指定数值,那么需要全部更改 例如,IP地址为192.168.200.30 其中200为重点,更改时为以下步骤 1、点击DHCP设置&#x…

贪吃蛇大作战(C语言--实战项目)

朋友们!好久不见。经过一段时间的沉淀,我这篇文章来和大家分享贪吃蛇大作战这个游戏是怎么实现的。 (一).贪吃蛇背景了解及效果展示 首先相信贪吃蛇游戏绝对称的上是我们00后的童年,不仅是贪吃蛇还有俄罗斯⽅块&…

找不到模块“vue-router”。你的意思是要将 moduleResolution 选项设置为 node,还是要将别名添加到 paths 选项中?

在tsconfig.app.json中添加,记得一定是 tsconfig.app.json 中,如添加到 tsconfig.node.json 还是会报错的 哈哈哈哈,不瞒你们,我就添加错了,哈哈哈。所以这也算写一个demo提醒自己 "compilerOptions": {&qu…

【牛客】排列计算

原题链接&#xff1a;登录—专业IT笔试面试备考平台_牛客网 目录 1. 题目描述 2. 思路分析 3. 代码实现 1. 题目描述 2. 思路分析 如果直接涂色来计算单点权重&#xff0c;2e5*2e5必然超时。 所以用差分进行优化。 3. 代码实现 #include<bits/stdc.h> using name…

Go语言fmt包深度探索:格式化输入输出的利器

&#x1f525; 个人主页&#xff1a;空白诗 文章目录 &#x1f3ad; 引言一、基础输出函数fmt.Print与fmt.Println&#x1f4cc; fmt.Print&#xff1a;纯粹输出&#xff0c;不带换行&#x1f4cc; fmt.Println&#xff1a;输出后自动添加换行符 二、格式化输出fmt.Printf&…

鸿蒙开发接口Ability框架:【@ohos.application.missionManager (missionManager)】

missionManager missionManager模块提供系统任务管理能力&#xff0c;包括对系统任务执行锁定、解锁、清理、切换到前台等操作。 说明&#xff1a; 本模块首批接口从API version 8开始支持。后续版本的新增接口&#xff0c;采用上角标单独标记接口的起始版本。 导入模块 impo…

“Postman 中文版使用教程:如何切换到中文界面?”

Postman 的很好用的接口测试软件。但是&#xff0c;Postman 默认是英文版的&#xff0c;也不支持在软件内切换为中文版。很多同学的英语并不是很好&#xff0c;看到一堆的英文很是头痛。 今天我们来介绍下&#xff1a;切换到 Postman 中文版的方法。想要学习更多的关于 Postma…

Type-C转音频(USB2.0数据传输)+PD充电芯片乐得瑞LDR6500/LDR6023

LDR6500 USB-C DRP 接口 USB PD 通信芯片概述 Type-C转音频(USB2.0数据传输)PD充电芯片乐得瑞LDR6500LDR6500是乐得瑞科技针对USB Type-C标准中的Bridge设备而开发的USB-C DRP&#xff08;Dual Role Port&#xff0c;双角色端口&#xff09;接口USB PD&#xff08;Power Deliv…

Qt---day2-信号与槽

1、思维导图 2、 拖拽式 源文件 #include "mywidget.h" #include "ui_mywidget.h" MyWidget::MyWidget(QWidget *parent) : QWidget(parent) , ui(new Ui::MyWidget) { ui->setupUi(this); //按钮2 this->btn2new QPushButton("按钮2",th…

LeetCode 面试经典150题 252.会议室

题目&#xff1a;给定一个会议时间安排的数组 intervals &#xff0c;每个会议时间都会包括开始和结束的时间 intervals[i] [starti, endi] &#xff0c;请你判断一个人是否能够参加这里面的全部会议。 思路&#xff1a;因为一个人在同一时刻只能参加一个会议&#xff0c;因此…

选择适用的无尘棉签:保障洁净生产环境下的高效擦拭

随着洁净生产条件的日益普及和无尘级别要求的提高&#xff0c;无尘擦拭用品成为广大用户追捧的必备工具。在这个领域&#xff0c;无尘棉签作为一种高效的擦拭工具&#xff0c;扮演着重要的角色。然而&#xff0c;面对市场上种类繁多的无尘棉签&#xff0c;如何选择最合适的产品…

linux 调试-kdb 调试内核-1

目标&#xff1a;打印bcm2835_spi_transfer_one 是如何从用户空间开始调用的 1. kernel 配置 KDB配置选项 添加 spi 控制器驱动 和 spi 设备驱动 2. 调试流程 调试内核-系统启动之后 1. 开发板进入kdb,等待pc 连接 rootraspberrypi:~# echo "ttyS0,115200"…
最新文章