PostgreSQL-CE PostgreSQL CE 8 Silver (PGCES-02) Free Practice Test
Question 1
Table "t1" is defined as follows:
CREATE TABLE t1 (value VARCHAR(5));
A set of SQL statements were executed in the following order.Select thenumber of rows that
table "t1" has after execution.
BEGIN;
INSERT INTO t1 VALUES ('AA');
SAVEPOINT point1;
INSERT INTO t1 VALUES ('BB');
SAVEPOINT point2;
INSERT INTO t1 VALUES ('CC');
ROLLBACK TO point1;
INSERT INTO t1 VALUES ('DD');
END;
CREATE TABLE t1 (value VARCHAR(5));
A set of SQL statements were executed in the following order.Select thenumber of rows that
table "t1" has after execution.
BEGIN;
INSERT INTO t1 VALUES ('AA');
SAVEPOINT point1;
INSERT INTO t1 VALUES ('BB');
SAVEPOINT point2;
INSERT INTO t1 VALUES ('CC');
ROLLBACK TO point1;
INSERT INTO t1 VALUES ('DD');
END;
Correct Answer: E
Question 2
The "sample" table consists of the following data:
How many rows are returned by executing the following SQL statement? SELECT i FROM sample
GROUP BY i HAVING count(*) = 2;
How many rows are returned by executing the following SQL statement? SELECT i FROM sample
GROUP BY i HAVING count(*) = 2;
Correct Answer: E
Question 3
Given the following two table definitions, select one SQL statement which will cause an error.
CREATE TABLE sample1 (id INTEGER, data TEXT);
CREATE TABLE sample2 (id INTEGER);
CREATE TABLE sample1 (id INTEGER, data TEXT);
CREATE TABLE sample2 (id INTEGER);
Correct Answer: C
Question 4
You want to set a constraint so that the "item_id" in the "sales" table will always have a value that
already exists as "id" in the "item_master" table. Select the correct SQL statement to fill in the
underlined blank of the "sales" table. Definitions:
CREATE TABLE item_master (
id INTEGER PRIMARY KEY,
name TEXT
);
CREATE TABLE sales (
sales_id INTEGER,
item_id INTEGER,
num INTEGER,
);
already exists as "id" in the "item_master" table. Select the correct SQL statement to fill in the
underlined blank of the "sales" table. Definitions:
CREATE TABLE item_master (
id INTEGER PRIMARY KEY,
name TEXT
);
CREATE TABLE sales (
sales_id INTEGER,
item_id INTEGER,
num INTEGER,
);
Correct Answer: C
Question 5
Based on the relationship of columns within a table, select the most suitable description that
shows that column A is dependent on column B.
shows that column A is dependent on column B.
Correct Answer: D
Question 6
Select the correct result generated by execution of the following SQL statements: CREATE
TABLE log (id int, message TEXT, logtime TIMESTAMP);
CREATE TABLE log_01 () INHERITS (log);
INSERT INTO log_01 VALUES (1, 'error', CURRENT_TIMESTAMP); SELECT * FROM log;
TABLE log (id int, message TEXT, logtime TIMESTAMP);
CREATE TABLE log_01 () INHERITS (log);
INSERT INTO log_01 VALUES (1, 'error', CURRENT_TIMESTAMP); SELECT * FROM log;
Correct Answer: D
Question 7
Choose the most suitable statement about user management of PostgreSQL.
Note: the version of PostgreSQL is 8.0.
Note: the version of PostgreSQL is 8.0.
Correct Answer: B
Question 8
The table "score" is defined as follows:
gid | score
-----+-------
1 | 70
1 | 60
2 | 100
3 | 80
3 | 50
The following query was executed. Select the correct result value.
SELECT score FROM score ORDER BY gid DESC, score ASC LIMIT 1;
gid | score
-----+-------
1 | 70
1 | 60
2 | 100
3 | 80
3 | 50
The following query was executed. Select the correct result value.
SELECT score FROM score ORDER BY gid DESC, score ASC LIMIT 1;
Correct Answer: B
Question 9
Select the most suitable statement about the creation of a new database.
Correct Answer: A
Question 10
Table "t1" is defined below.
Table "t1" has a column "id" of type INTEGER, and a column "name" of type TEXT.
t1:
The following SQL is executed while client "A" is connected. BEGIN;
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
SELECT * FROM t1 WHERE id = 1 FOR UPDATE; -- (*)
While the second 'SELECT' statement, shown with (*), is being executed, a separate client "B"
connects and executes the following SQL.
Select the correct statement about the execution results.
UPDATE t1 SET name = 'turtle' WHERE id = 2;
Note: the default transaction isolation level is set to "read committed".
Table "t1" has a column "id" of type INTEGER, and a column "name" of type TEXT.
t1:
The following SQL is executed while client "A" is connected. BEGIN;
SELECT * FROM t1 WHERE id = 2 FOR UPDATE;
SELECT * FROM t1 WHERE id = 1 FOR UPDATE; -- (*)
While the second 'SELECT' statement, shown with (*), is being executed, a separate client "B"
connects and executes the following SQL.
Select the correct statement about the execution results.
UPDATE t1 SET name = 'turtle' WHERE id = 2;
Note: the default transaction isolation level is set to "read committed".
Correct Answer: C