SUPERSETEQ 연산자

설명

SUPERSETEQ 연산자는 첫 번째 피연산자가 두 번째 피연산자의 모든 원소를 포함하거나 서로 동일한 경우, 즉 두 번째 피연산자가 첫 번째 피연산자의 부분집합인 경우 TRUE(1)를 반환한다. 단, 피연산자가 모두 LIST 타입인 경우에는 SUPERSETEQ 연산을 지원하지 않는다.

구문

collection_operand SUPERSETEQ collection_operand

예제

--selecting rows when the first operand is a superset of the second operand

SELECT id, name, address, zip_code FROM contain_tbl WHERE address SUPERSETEQ {'country','state','city'};

 

=== <Result of SELECT Command in Line 1> ===

 

           id  name                  address               zip_code

===============================================================================

            3  'Jones     '          {'city', 'country', 'state'}  {1, 2, 3, 4}

            4  'Smith     '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 4}

            5  'Kim       '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 4}

            6  'Smith     '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 5}

            7  'Brown     '          {'city', 'country', 'state', 'street'}  {}

 

5 rows selected.

 

--SUPERSETEQ operator cannot be used for comparison between LIST and LIST type values

SELECT id, name, address, zip_code FROM contain_tbl WHERE zip_code SUPERSETEQ {1,2,3};

 

ERROR: ' superseteq ' operator is not defined on types sequence and sequence.

 

--Comparing operands with a SUPERSETEQ operator after casting LIST type as SET type

SELECT id, name, address, zip_code FROM contain_tbl WHERE zip_code SUPERSETEQ (CAST ({1,2,3} AS SET));

 

 

=== <Result of SELECT Command in Line 1> ===

 

           id  name                  address               zip_code

===============================================================================

            1  'Kim       '          {'country', 'state'}  {1, 2, 3}

            3  'Jones     '          {'city', 'country', 'state'}  {1, 2, 3, 4} 

            4  'Smith     '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 4}

            5  'Kim       '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 4}

            6  'Smith     '          {'city', 'country', 'state', 'street'}  {1, 2, 3, 5}

 

5 rows selected.