1.
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 number of rows in the result. SELECT gid,
max(score) FROM score
GROUP BY gid HAVING max(score) > 60;
2.
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;
3.
The "sample" table consists of the following data:
How many rows are returned by executing the following SQL statement? SELECT DISTINCT ON
(data) * FROM sample;
4.
The following SQL statements were executed using psql.
Select the appropriate statement about the result.
LISTEN sign_v;
BEGIN;
NOTIFY sign_v;
COMMIT;
LISTEN sign_v;
5.
Select the correct SQL statement which concatenates strings 'ABC' and 'abc' to form 'ABCabc'.
6.
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".
7.
The table "custom" is defined below.
The "id" column and "introducer" column are of INTEGER type, and the "email" column is of TEXT
type.
id | email | introducer
----+-----------------+------------
2 | aaa@example.com | 1
3 | bbb@example.com | 2
4 | ccc@example.com | 2
Three SQL statements were executed in the following order: INSERT INTO custom
SELECT max(id) + 1, 'ddd@example.com', 4 FROM custom;
UPDATE custom SET introducer = 999
WHERE email = 'bbb@example.com';
DELETE FROM custom
WHERE introducer NOT IN (SELECT id FROM custom);
Select the number of rows in the "custom" table after the execution.
8.
The "sample" table consists of the following data:
How many rows are returned by executing the following SQL statement? SELECT * FROM
sample WHERE v ~ 'ab';
9.
Select an incorrect statement regarding the following SQL statement. Note that "user_view" is a view.
CREATE OR REPLACE RULE rule_1 AS ON UPDATE TO user_view DO INSTEAD NOTHING;
10.
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);