Sample Exam Questions

From the objective of OSS-DB Exam Silver
- Operation and Management - Backup method

Sample Question


Choose the two most appropriate descriptions for the SQL COPY statement.

  1. It is defined in standard SQL and can be used with many RDBMS, including PostgreSQL.
  2. The \copy meta command of psql internally executes the SQL COPY statement.
  3. In order to execute the COPY statement, the database administrator authority is required.
  4. Input and output files of CSV (Comma Separated Values) format by default.
  5. When restoring from a text format backed up by using pg_dump command, the COPY statement is used by default.

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

Answer and Explanation

COPY is a proprietary extension of PostgreSQL that is not found in the standard SQL. You can output the contents of the table to a tab-delimited or comma-delimited text file, or you can import the text file and copy it to the table. By default, tab-delimited files are input and output.

When specifying a file name as an input / output destination of COPY, this is a file on the database server, and administrator authority is required for execution. However, if STDIN or STDOUT is specified, it can be executed with the privileges of general users.

The \copy meta command of psql is an interface connecting the file on the client machine and the COPY command, internally the COPY command is executed.

If you open the output file of the pg_dump command with a text editor, the data of the table with COPY FROM STDIN after CREATE TABLE is described. That is, when restoring, the COPY statement is executed. If - inserts is specified as an option when executing the pg_dump command, the INSERT statement is used instead of the COPY statement. For example, it would be useful when you want to restore with an RDBMS other than PostgreSQL.

Therefore, the correct answers are B and E.