CS FundamentalsHardGATE CS (PYQ pattern)
Table UP(a, b): (1,10), (2,20), (3,30). After UPDATE UP SET a = b, b = a; (standard SQL semantics), what is the sum of column a and the sum of column b?
- A. 60 and 6
- B. 60 and 60
- C. 6 and 6
- D. 54 and 12
Correct answer: A. 60 and 6
In standard SQL all right-hand sides see the OLD row values, so the assignments swap the columns: a becomes (10, 20, 30) and b becomes (1, 2, 3). An implementation that assigned sequentially would make both columns equal.
More DBMS and SQL questions
- Table DU(a, b): (1,NULL), (1,NULL), (2,3), (2,3), (NULL,5), (NULL,5), (1,2). Let x = rows returned by SELECT DISTINCT a, b FROM DU, y =…
- R(A, B) and S(B) are relations. Which relational-algebra expression computes the division R ÷ S (the A-values that are paired in R with…
- R(A, B): (1,x), (2,y), (3,z), (4,NULL). S(B, C): (x,10), (x,11), (y,20), (w,30), (NULL,40). How many rows does SELECT FROM R FULL OUTER…
- R(A, B) = {(1,2), (1,3), (2,3), (3,4), (4,1)} is a graph's edge set. How many tuples are in the relation π{A,D}(ρ(R) ⋈{R.B = R2.A} ρ(R2))…
- Multiple-granularity locking (modes IS, IX, S, SIX, X with the standard compatibility matrix). T1 holds IX on table TB and S on row r1 of…
- Snapshot isolation with first-committer-wins: a transaction aborts at commit time if some other transaction that committed after it…