psql but receive an error when running a SELECT query. What might be the issue?
user_id is 10, setting the status to ‘active’. Which query would achieve this?
BEGIN TRANSACTION, make some updates, but then decide not to save the changes. Which command should you use to discard the changes?
| Qno | Answer |
|---|---|
| 1 | B) 5432 |
| 2 | A) postgres |
| 3 | A) The table does not exist in the database |
| 4 | A) If the table contains any data |
| 5 | B) TEXT |
| 6 | A) CHECK (column >= 0) |
| 7 | A) UPDATE users SET status = ‘active’ WHERE user_id = 10; |
| 8 | B) The insert will fail with a “unique violation” error |
| 9 | D) TRUNCATE TABLE table_name; |
| 10 | B) Create an index on the columns involved in the WHERE clause |
| 11 | A) CREATE INDEX idx_name ON table_name (column_name); |
| 12 | B) Implement locking and isolation levels |
| 13 | A) ROLLBACK; |
| 14 | A) JOIN between users and purchases with a subquery filtering by date |
| 15 | A) Use a LEFT JOIN with a WHERE clause filtering for NULL order IDs |
| 16 | A) Create a view with SELECT queries |
| 17 | B) Use a materialized view with periodic refresh |
| 18 | A) Create a composite index on the columns used in the WHERE clause |
| 19 | C) Composite index covering all relevant columns |
| 20 | D) All of the above |
| 21 | A) Function |
| 22 | A) Trigger |
| 23 | A) COPY table_name FROM ‘file.csv’ WITH CSV; |
| 24 | A) COPY table_name TO ‘file.csv’ WITH CSV; |
| 25 | B) Add an index on the columns used in JOIN conditions |
| 26 | A) Use indexes on the columns involved in aggregation |
| 27 | D) Both A and B |
| 28 | B) Sharding |
| 29 | B) Physical replication |
| 30 | D) All of the above |