pg的编译安装
--without-readline
阻止使用Readline库(和libedit),该选项将关闭在psql中编辑命令行和历史命令,所以我们不建议使用该选项。
LDFLAGS='-Wl,-rpath='"'"'$$ORIGIN/../lib'"'"',--disable-new-dtags' ./configure '--prefix=/root/pgsql' '--with-systemd' '--with-extra-version=iadm' '--with-system-tzdata=/usr/share/zoneinfo' '--disable-rpath' --without-readline
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
问题及解决方法
问题1:
configure: error: Package requirements (icu-uc icu-i18n) were not met:No package 'icu-uc' found
No package 'icu-i18n' found
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install libicu-devel.aarch64
问题2:
configure: error: could not determine flags for linking embedded Perl.
This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is notinstalled.
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install perl-ExtUtils-Embed -y
问题3:
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y readline readline-devel
问题4:
configure: error: library 'pam' is required for PAM
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y pam pam-devel
问题5:
configure: error: library 'xml2' (version >= 2.6.23) is required for XML support
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y libxml2 libxml2-devel
问题6:
configure: error: library 'xslt' is required for XSLT support
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y libxslt-devel.aarch64
问题7:
configure: error: library 'ldap' is required for LDAP
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y openldap-devel.aarch64
问题8:
configure: error: header file is required for systemd support
解决办法:
[root@ecs-cs01-0001 postgresql-10.9]# yum install -y systemd-devel.aarch64
schema
schema概念有点像命名空间或者把它想象成一个文件系统中的目录,差别就是这个schema下不能再有schema嵌套。
各个对象比如表、函数等存放在各个schema下,同一个schema下不能有重复的对象名字,但在不同schema下可以重复。
role
官网上的描述是:
CREATE USER is now an alias for CREATE ROLE. The only difference is that when the command is spelled CREATE USER, LOGIN is assumed by default, whereas NOLOGIN is assumed when the command is spelled CREATE ROLE.
也就是说role和user区别不大,create user默认有login权限,而create role没有
问题
- 在有数据的数据表上创建索引时报错: index row size 2768 exceeds btree version 4 maximum 2704
pg的这个限制,是硬限制,因为btree分叉,少于3条就会不够分。除非在编译pg时,–with-blocksize参数设置为16k或者32k,默认8k。
- 如果插入的数据超过了索引的长度限制2704字节,会发生什么?
这条数据会插入失败
global目录介绍
postgres数据库中,base/*/2601 文件为何都是一样的
global名如其意,存放的文件用于存储全局的系统表信息和全局控制信息。
global下有四种文件:
- pg_control 用于存储全局控制信息
- pg_filenode.map 用于将当前目录下系统表的OID与具体文件名进行硬编码映射(每个用户创建的数据库目录下也有同名文件)。
- pg_internal.init 用于缓存系统表,加快系统表读取速度(每个用户创建的数据库目录下也有同名文件)。
- 全局系统表文件 数字命名的文件,用于存储系统表的内容。它们在pg_class里的relfilenode都为0,是靠pg_filenode.map将OID与文件硬编码映射。(注:不是所有的系统表的relfilenode都为0)
data
├── global # under global, all the filenode is hard-code(select oid,relname,relfilenode from pg_class where relfilenode=0 order by oid;)
│ ├── 1136 # pg_pltemplate
│ ├── 1137 # pg_pltemplate_name_index
│ ├── 1213 # pg_tablespace
│ ├── 1214 # pg_shdepend
│ ├── 1232 # pg_shdepend_depender_index
│ ├── 1233 # pg_shdepend_reference_index
│ ├── 1260 # pg_authid
│ ├── 1261 # pg_auth_members
│ ├── 1262 # pg_database
│ ├── 2396 # pg_shdescription
│ ├── 2397 # pg_shdescription_o_c_index
│ ├── 2671 # pg_database_datname_index
│ ├── 2672 # pg_database_oid_index
│ ├── 2676 # pg_authid_rolname_index
│ ├── 2677 # pg_authid_oid_index
│ ├── 2694 # pg_auth_members_role_member_index
│ ├── 2695 # pg_auth_members_member_role_index
│ ├── 2697 # pg_tablespace_oid_index
│ ├── 2698 # pg_tablespace_spcname_index
│ ├── 2846 # pg_toast_2396
│ ├── 2847 # pg_toast_2396_index
│ ├── 2964 # pg_db_role_setting
│ ├── 2965 # pg_db_role_setting_databaseid_rol_index
│ ├── 2966 # pg_toast_2964
│ ├── 2967 # pg_toast_2964_index
│ ├── 3592 # pg_shseclabel
│ ├── 3593 # pg_shseclabel_object_index
│ ├── 4060 # pg_toast_3592x
│ ├── 4061 # pg_toast_3592_index
│ ├── 6000 # pg_replication_origin
│ ├── 6001 # pg_replication_origin_roiident_index
│ ├── 6002 # pg_replication_origin_roname_index
│ ├── pg_control # global control file, use pgcheck -pc to see it.
│ ├── pg_filenode.map # system table (oid -> filenode) mapping file, use pgcheck -pm to see it.
│ └── pg_internal.init # system table cache file, use pgcheck -pr to see it.
单引号和双引号的区别
- 双引号(""):用于引用标识符(如表名、列名等)。默认情况下,PostgreSQL会自动将未用双引号括起来的标识符转换为小写处理。
- 单引号(’’):主要用于表示字符串常量。