SUPERSET 연산자

설명

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

구문

collection_operand SUPERSET collection_operand

예제

--selecting rows when the first operand is a superset of the second operand and they are not same

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

           id  name                  address               zip_code

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

            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'}  {} 

 

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

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

 

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

 

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

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

           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}