Versions available for this page: CUBRID 8.2.1 | CUBRID 8.3.0 | CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |
SELECT 문은 지정된 테이블에서 원하는 컬럼을 조회한다.
SELECT [ qualifier ] select_expression [ { TO | INTO }
variable [ {, variable } ] ]
qualifier :
ALL
DISTINCT
UNIQUE
select_expression :
*
table_name. *
expression [ {, expression}...]
variable :
[:] identifier
다음은 역대 올림픽이 개최된 국가를 중복 없이 조회한 예제이다. 이 예제는 olympic 테이블에서 host_nation 값이 다른 리스트를 결과로 만든다.
DISTINCT 또는 UNIQUE 키워드는 질의 결과가 유일한 값만을 갖도록 만든다. 예를 들어 host_nation 값이 'Greece'인 olympic 인스턴스가 여러 개일 때 질의 결과에는 하나의 값만 나타나도록 할 경우에 사용된다.
SELECT DISTINCT host_nation FROM olympic;
=== <Result of SELECT Command in Line 1> ===
host_nation
======================
'Australia'
'Belgium'
'Canada'
'Finland'
'France'
...
18 rows selected.
다음은 역대 올림픽의 모든 정보를 조회하는 예제이다. 컬럼 전체를 조회하기 위해서는 컬럼 이름 리스트 대신 별표(*)가 사용될 수 있다. 조회 결과는 테이블 내에서 정의된 순서에 따라 컬럼 값이 표시된다.
SELECT * FROM olympic;
=== <Result of SELECT Command in Line 1> ===
host_year host_nation host_city opening_date closing_date mascot slogan introduction
=======================================================================================================
1988 'Korea' 'Seoul' 09/17/1988 10/02/1988 'HODORI' 'Harmony and progress' 'The 1988 Seoul Games were the first Olympics to allow professional athletes to compete in certain events…
1992 'Spain' 'Barcelona ' 07/25/1992 08/09/1992 'Cobi' 'Friends Forever ' 'For the first time in decades, no nations boycotted the 1992 Barcelona Games…
1996 'United States of America' 'Atlanta ' 07/19/1996 08/09/1996 'Izzy' 'The Celebration of the Century ' 'The 1996 Atlanta Games celebrated 100 years of the Modern Olympic Games.
...
25 rows selected.