首页 > 数据库 >openGauss与postgresql日常使用差异

openGauss与postgresql日常使用差异

时间:2024-03-14 17:58:33浏览次数:26  
标签:insert postgresql into col1 dt 日常 openGauss mydb id

openGauss 与 postgresql 日常使用差异

密码加密

  • postgresql 默认密码加密方式是 md5。

  • openGauss 默认密码加密方式是 sha256。

  • 使用 navicate、pgadmin3 等客户端开发工具访问 og,需要修改加密方式。

  • 如果在本地用用户名密码登陆数据库没问题。

  • 但是用其他工具连接数据库报用户或密码错误。

  • 可能是密码加密方式不对,需要看 pg_hba.conf 及 参数。

password_encryption_type = 0		#Password storage type, 0 is md5 for PG, 1 is sha256 + md5, 2 is sha256 only

字符串存储

在 postgresql 里,char(n)、varchar(n) n 代表是字符;最多存储 1GB。

在 openGauss 里,char(n)、varcahr(n) n 代表的是字节,nvarchar2(n) n 代表是字符;最多存储 100MB。

---
---postgresql字符测试
---
postgres=# \d dt
                       Table "public.dt"
 Column |         Type         | Collation | Nullable | Default
--------+----------------------+-----------+----------+---------
 id     | integer              |           |          |
 col1   | character varying(8) |           |          |

postgres=# insert into dt values(3,'中文字符长度测试');
INSERT 0 1
postgres=# insert into dt values(4,'yingwen8');
INSERT 0 1
postgres=# insert into dt values(4,'yingwen88');
ERROR:  value too long for type character varying(8)

---
---openGauss字符测试
---
mydb=# \d+ dt
                                 Table "public.dt"
 Column |         Type         | Modifiers | Storage  | Stats target | Description
--------+----------------------+-----------+----------+--------------+-------------
 id     | integer              |           | plain    |              |
 col1   | character varying(8) |           | extended |              |
 col2   | nvarchar2(8)         |           | extended |              |
Has OIDs: no
Options: orientation=row, compression=no

mydb=# insert into dt(id,col1) values(3,'yingwen8');
INSERT 0 1
mydb=# insert into dt(id,col1) values(3,'yingwen88');
ERROR:  value too long for type character varying(8)
CONTEXT:  referenced column: col1
mydb=# insert into dt(id,col1) values(3,'中文测试');
ERROR:  value too long for type character varying(8)
CONTEXT:  referenced column: col1
mydb=# insert into dt(id,col1) values(3,'中文测');
ERROR:  value too long for type character varying(8)
CONTEXT:  referenced column: col1

mydb=# insert into dt(id,col2) values(4,'中文字符长度测试');
INSERT 0 1
mydb=# insert into dt(id,col2) values(4,'yingwen8');
INSERT 0 1
mydb=# insert into dt(id,col2) values(4,'yingwen88');
ERROR:  value too long for type nvarchar2(8)
CONTEXT:  referenced column: col2
mydb=#

null 与 空字符

  • 在 postgresql 里 null != ‘’

  • 在 openGauss 里‘’转换成 null,没有‘’

----+------

---
---postgresql测试
---
postgres=# create table dt(id int,col1 varchar(8));
CREATE TABLE
postgres=# insert into dt values(1,null);
INSERT 0 1
postgres=# insert into dt values(2,'');
INSERT 0 1
postgres=# select * from dt;
 id | col1
----+------
  1 |
  2 |
(2 rows)

postgres=# select * from dt where col1 is null;
 id | col1
----+------
  1 |
(1 row)

postgres=# select * from dt where col1='';
 id | col1
----+------
  2 |
(1 row)

postgres=#
---
---openGauss测试
---
mydb=# create table dt(id int,col1 varchar(8));
CREATE TABLE
mydb=# insert into dt values(1,null);
INSERT 0 1
mydb=# insert into dt values(1,'');
INSERT 0 1
mydb=# select * from dt;
 id | col1
----+------
  1 |
  1 |
(2 rows)

mydb=# select * from dt where col1 is null;
 id | col1
----+------
  1 |
  1 |
(2 rows)

mydb=# select * from dt where col1='';
 id | col1
----+------
(0 rows)

mydb=#

标签:insert,postgresql,into,col1,dt,日常,openGauss,mydb,id
From: https://www.cnblogs.com/renxyz/p/18073583

相关文章

  • PostgreSQL与openGauss之分区性能
    PostgreSQL与openGauss之分区性能概述PostgreSQL与openGauss分区表定义差异,请参考https://www.modb.pro/db/41393。openGauss1.1.0开始支持hash/list分区,hash分区表最多支持64个分区,否则会报:ERROR:Un-supportfeatureDETAIL:Thepartition’slengthshouldbe......
  • PostgreSQL与openGauss之关键字
    PostgreSQL与openGauss之关键字日常数据库运维的过程中可能对数据库关键字关注点并不是很高,但在程序开发的过程中,数据库对象建模要尽可能的避开数据库关键字的使用,否则在后续开发过程中需要用到各种转译的方法来将关键字转换为普通字符,会非常的麻烦。最近在openGauss上执行......
  • openGauss分区使用样例
    openGauss分区使用样例概述openGauss1.1.0版本开始,分区方式分为三种,分别是RANGE、HASH和LIST,官方文档中对于分区表的使用样例比较少,这里对各种分区使用方式做一下整理,方便以后快速调整使用。范围分区VALUESLESSTHAN语法格式分区策略的分区键最多支持4列分区键支持......
  • openGauss行存与列存
    openGauss行存与列存列存表限制列存表不支持数组。列存表的数量建议不超过1000个。列存表的表级约束只支持PARTIALCLUSTERKEY,不支持主外键等表级约束。列存表的字段约束只支持NULL、NOTNULL和DEFAULT常量值。列存表不支持alter命令修改字段约束。列存表支持......
  • openGauss监控之exporter部署
    openGauss监控之exporter部署概述opengauss_exporter是为openGauss数据库量身打造的数据采集工具,配合当前最受欢迎的监控报警框架prometheus+grafana组合实时展示数据库信息,为openGauss数据库的平稳运行保驾护航。opengauss_exporter同openGauss数据库一样是开源......
  • PostgreSQL从入门到精通教程 - 第46讲:poc-tpch测试
       PostgreSQL从小白到专家,是从入门逐渐能力提升的一个系列教程,内容包括对PG基础的认知、包括安装使用、包括角色权限、包括维护管理、、等内容,希望对热爱PG、学习PG的同学们有帮助,欢迎持续关注CUUGPG技术大讲堂。 第46讲:POC-TPCH测试  内容1:TPC-H介绍内容2:TPC-H......
  • MogDB openGauss 角色切换后sequence为什么不连续
    本文出处:https://www.modb.pro/db/569272背景今天在客户现场做高可用切换测试,为了验证数据库节点角色切换后无数据丢失,我单独创建一张使用了自增sequence的表,通过vip方式访问数据库,并1s插入一条数据。因为数据库本身是通过benchmarksql工具加压的,数据库服务器的CPU使......
  • MogDB openGauss wal日志解析工具 mog_xlogdump
    MogDB/openGausswal日志解析工具mog_xlogdump本文出处:https://www.modb.pro/db/398124概述mog_xlogdump是云和恩墨独立开发的wal日志离线解析工具。熟悉PG的小伙伴应该都使用pg_xlogdump/pg_waldump查看过PG数据库的wal文件,解析的wal数据结果是没有办法直接拿......
  • MogDB-openGauss default privileges 使用方法
    MogDB/openGaussdefaultprivileges使用方法权限是用户访问数据库对象的首要条件,每个新增用户默认属于PUBLIC角色组成员,也就是具有PUBLIC角色组的权限,但在日常业务使用中,仅仅具有PUBLIC权限是远远不够的,还需要具有额外的权限,在MogDB/openGauss数据库支持的业务中经常需......
  • openGauss 由于RemoveIPC未关闭导致数据库crash
    openGauss由于RemoveIPC未关闭导致数据库crashsemop引发的数据库crash--主库FATAL:semop(id=xxxxx)failed:IdentifierremovedFATAL:semctl(xxxxxx,11,SETVAL,0)failed:Invalidargument--备库FATAL:semctl(xxxxxx,11,SETVAL,0)failed:InvalidargumentLOG......