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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!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