Sample Exam Questions

From the objective of OSS-DB Exam Silver
S3.1 SQL commands (SELECT statement)

Sample Question

3.49

In psql, a SELECT from the 'test' table produced the following output:

=> select * from test;
 a | b
---+---
 a | b
(1 line)

For this table, what does the output look like when you run 'select a b from test;'?


  1. a
    ---
    a

  2. a
    ---
    b

  3. b
    ---
    a

  4. b
    ---
    b
  5. None of the above. 

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/02

Answer and Explanation

The most basic form of a SELECT statement is: SELECT column_name FROM table_name WHERE conditional_expression.

If you specify * for the column_name, you are specifying all columns in the table, and if you omit WHERE clause, all rows in the table are selected. This is the SELECT statement at the beginning of this question, and you can see that the table has two columns, a and b, and contains only one row of data, where the value in column a is a and the value in column b is b.

You can specify multiple column names separated by commas, but in this question the column_name is specified as "a b" with no commas. In fact, you can specify display names in column_name, in addition to the table column names and expressions. In this case, a is the column name, and b is the display name. Note that "a as b" has the same meaning. The display name appears as the column name in psql and other output, and is also used as the column name in a view.

In the SELECT statement of this question, the column name is displayed as b, but the displayed data is the value of the column a, which is a.

Therefore, the correct answer is C.