ZhangZhihui's Blog  

 

     inet

 

 

 

 The essential difference between inet and cidr data types is that inet accepts values with nonzero bits to the right of the netmask, whereas cidr does not. For example, 192.168. 0.1/24 is valid for inet but not for cidr .

 

Say, if you have a /8 netmask, the cidr type requires that all the 24 rightmost bits are zero. inet does not have this requirement.

db=# select '255.0.0.0/8'::cidr;
255.0.0.0/8

db=# select '255.1.0.0/8'::cidr;
ERROR:  invalid cidr value: "255.1.0.0/8"
DETAIL:  Value has bits set to right of mask.

And inet allows this:

db=# select '255.1.0.0/8'::inet;
255.1.0.0/8

     cidr

 

 

Prefer jsonb.

               

 

 

 

          @>

 

               unnest()

 

 

     split_part()

 

Text Search Vector

     to_tsvector()

Text Search Query

     to_tsquery(), @@

 

 

 

 

     bit

 

zzhtest=> select B'0101'   -- user's feature flags
               & B'0001'   -- mask: if the result equals the mask, the user has that feature
----------
 0001

 

create table bits (
    bit3 bit(3),
    bitv bit varying(32)  -- up to 32 bits
);

 

复制代码
select '[1,5]'::int4range;
-- [1,6)
-- 5.99 is not valid

select '[1,5]'::numrange;
-- [1,5]
-- 5.99 is valid but not included

select '[1,6)'::int4range;
-- [1,6)
-- 5.99 is not valid

select '[1,6)'::numrange;
-- [1,6)
-- 5.99 is valid and included
复制代码

 

 

 

复制代码
select numrange(1, 5);
-- [1,5)

select int4range(1, 5);
-- [1,5)

select numrange(1, 5, '[]');
-- [1,5]

select numrange(1, 5, '(]');
-- (1,5]

select int2range(1, 5, '[]');
ERROR:  function int2range(integer, integer, unknown) does not exist
LINE 1: select int2range(1, 5, '[]');
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

select int4range(1, 5, '[]');
-- [1,6)
复制代码

 

     @>, &&

 

 

     upper_inc()

 

 

 

 

 

 

 

 

 

     &&

 

 

 

 

The difference between 'no action' and 'restrict' is very sutle.'no action' allows the check to be deferred to later in a transaction whereas 'restrict' does not allow that check to be deferred to later in a transaction, but at the end of the day, the result is the same, you can not delete the parent row without first deleting the child row, but you can change that by same CASCADE.

 

posted on   ZhangZhihuiAAA  阅读(3)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-12-04 ZIMP - Mock DB for testing HTTP API in go
2023-12-04 Viper - Read multiple config files
 
点击右上角即可分享
微信分享提示