173 views
4 4 votes

Consider the relation

$\text{Student(sid,\ name,\ age)}$

where the attributes occur in the schema in the order shown.

Which of the following statements correctly inserts the tuple with $\text{sid} = 5$, $\text{name}=\text{'Mira'}$, and $\text{age}=20$?

  1. $\text{INSERT\ INTO\ Student\ VALUES\ (5,\ 'Mira',\ 20);} $
     
  2. $\text{INSERT\ INTO\ Student(name,\ sid,\ age)\ VALUES\ ('Mira',\ 5,\ 20);} $
     
  3. $\text{INSERT\ INTO\ Student(name,\ sid,\ age)\ VALUES\ (5,\ 'Mira',\ 20);} $
     
  4. Both A and B

1 Answer

0 0 votes

In statement A, the attribute list is omitted.

Therefore, the values correspond to the attributes in the schema order:

$\text{sid, name, age}$

Thus, $(5,\text{'Mira'},20)$ is inserted correctly.

So A is valid.

In statement B, an explicit attribute list is supplied:

$\text{name, sid, age}$

The values are correspondingly

$\text{'Mira'}$, $5$, $20$.

Therefore, this also inserts the same tuple correctly.

So B is valid.

In statement C, the first specified attribute is $\text{name}$, but the first supplied value is $5$.

Similarly, the second attribute is $sid$, but the second value is $'\text{Mira}'$.

Therefore, the values do not correspond correctly to the stated attributes.

So C is incorrect.

Hence, both A and B are correct.

Answer:
Position:
Show:

Related questions

3 3 votes
1 1 answer
143
143 views
GO Classes asked Sep 3
143 views
A table contains the following attributes:$\text{code\ CHAR(6)}$$\text{name\ VARCHAR(10)}$Which of the following statements are correct?A value of $\text{code}$ has a fix...
4 4 votes
1 1 answer
294
294 views
GO Classes asked Sep 3
294 views
Suppose the relation $R(A)$ exists and currently contains several tuples.The following SQL statements are executed in sequence:$\text{DELETE\ FROM\ R;}$$\text{INSERT\ INT...
2 2 votes
1 1 answer
166
166 views
GO Classes asked Sep 3
166 views
A relation $R(A,B)$ currently contains $7$ tuples.The following SQL statement is executed:$\text{ALTER\ TABLE\ R\ ADD\ C\ INTEGER;}$Immediately after this command, and be...
3 3 votes
1 1 answer
125
125 views
GO Classes asked Sep 3
125 views
Consider the following SQL statements:$\text{CREATE\ TABLE\ Student\ (sid\ INTEGER,\ name\ VARCHAR(20));}$ $\text{ALTER\ TABLE\ Student\ ADD\ age\ INTEGER;}$ $\text{UPDAT...