博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Row and Array Comparisons
阅读量:4582 次
发布时间:2019-06-09

本文共 2384 字,大约阅读时间需要 7 分钟。

Row-wise Comparison:
row的定义:
row与row的比较可以使用符号:
=, <>, <, <=, > or >=
digoal=# select row(a.foosubid) from foo a limit 1;                             row ----- (2)(1 row)digoal=# select row(a.foosubid) = row(2) from foo a limit 1;   ?column? ---------- t(1 row)digoal=# select row(a.foosubid) = row('2') from foo a limit 1;  ?column? ---------- t(1 row)digoal=# select row(a.foosubid) = row(22) from foo a limit 1; ?column? ---------- f(1 row)

is distinct from:
digoal=# select row(a.foosubid) is distinct from row(1) from foo a limit 1;  ?column? ---------- t(1 row)digoal=# select row(a.foosubid) is distinct from row(2) from foo a limit 1;           ?column? ---------- f(1 row)

Any,All:
array:

expression operator ANY (array expression) expression operator SOME (array expression)

expression operator ALL (array expression)

demo:
 
digoal=# create table tx (a int, b int[], c int[][]);     CREATE TABLEdigoal=# insert into tx values(1, '{1,2,3,4}', '{
{1,2,3,4,5},{1,2,3,4,5}}');INSERT 0 1digoal=# insert into tx values(1, '{1,2,3,4}', '{
{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}');INSERT 0 1digoal=# insert into tx values(1, '{1,2,3,4}', '{
{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5},{4,2}}');ERROR: malformed array literal: "{
{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5},{4,}}"LINE 1: insert into tx values(1, '{1,2,3,4}', '{
{1,2,3,4,5},{1,2,3,4... ^digoal=# select * from tx; a | b | c ---+-----------+--------------------------------------- 1 | {1,2,3,4} | {
{1,2,3,4,5},{1,2,3,4,5}} 1 | {1,2,3,4} | {
{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}(2 rows)digoal=# select c[1][1] from tx; c --- 1 1(2 rows)digoal=# select c[0][0] from tx; c --- (2 rows)digoal=# select c[1][2] from tx; c --- 2 2(2 rows)digoal=# select * from tx where 4 =any( c); a | b | c ---+-----------+--------------------------------------- 1 | {1,2,3,4} | {
{1,2,3,4,5},{1,2,3,4,5}} 1 | {1,2,3,4} | {
{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}}(2 rows)digoal=# select * from tx where 4 =all( c); a | b | c ---+---+---(0 rows)digoal=# insert into tx values(1, '{1,2,3,4}', array[[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]); INSERT 0 1digoal=# select 2= any( array(select fooid from foo)); ?column? ---------- t(1 row)

 

 

转载于:https://www.cnblogs.com/xxvv/p/3766260.html

你可能感兴趣的文章
winform 获取当前名称
查看>>
opengl glut vs2013配置
查看>>
Module模式
查看>>
netfilter/iptables全攻略
查看>>
wpf Smith.WPF.HtmlEditor 使用方法
查看>>
PDO分页
查看>>
MyBatis笔记一:GettingStart
查看>>
查找不同的木棍
查看>>
面试题:顺时针打印矩阵
查看>>
DataSet、DataTable、DataRow、DataColumn区别及使用实例
查看>>
python 特殊方法
查看>>
Python3 练习笔记四
查看>>
装箱问题
查看>>
Android线程管理(一)——线程通信
查看>>
vim 使用技巧
查看>>
Periodic String UVa1225
查看>>
Android 演示 DownloadManager——Android 下载 apk 包并安装
查看>>
【转】正则应用实例,如将多个空格改为1个空格
查看>>
移动端自动打包平台
查看>>
谈一谈git和SVN两大版本管理工具。
查看>>