Академический Документы
Профессиональный Документы
Культура Документы
1. Which of the following statements is likely to have created the Persons table?
2. What will happen if we execute the following sequence of statements, one after the other?
Assume the table is currently empty and that if a warning is issued, then the statement is
assumed to fail.
3. Which column is most likely the primary key for this table?
a. Name
b. Type
c. BirthDate
d. Price
4. We want to add a new pet squirrel named "Chippy" to this table. Which of the following
queries will add this pet?
a.
INSERT INTO Pets(Name, Type, Sex, Price, Birthdate)
WHERE ('Chippy', 'Squirrel', 'M', '20', '04-05-2005')
b.
INSERT INTO Pets(Name, Type, Sex, Price, Birthdate)
VALUES ('Chippy', 'Squirrel', 'M', '20', '04-05-2005')
c.
INSERT INTO Pets
WHERE Name = 'Chippy' AND Type = 'Squirrel' AND Sex = 'M'
AND Price = 20 AND Birthdate = '04-05-2005'
d.
INSERT INTO Pets
WHERE Name = 'Chippy' OR Type = 'Squirrel' OR Sex = 'M'
OR Price = 20 OR Birthdate = '04-05-2005'
5. What would the following query return?
SELECT COUNT(DISTINCT Weight)
FROM Pets
a. 12
b. 13
c. 8
d. 11
a. 11
b. 12
c. 8
d. 13
a. 0
b. NULL
c. 7
d. None of the above
Use the following STUDENTS table to answer the NEXT TWO questions.
8. All students having a GPA less than 3.00 have to be removed from the Gradebook
database. Which of the following queries will delete them from the Students table?
a.
delete * from Students
where GPA < 3.00
b.
delete Students
where GPA < 3.00
c.
delete from Students
where GPA < 3.00
d.
select *
delete from Students
where GPA < 3.00
9. Which of the following queries is a correct way to calculate a mean GPA for freshman and
sophomore students?
a.
select sum(GPA)
from Students
where Year = "FR" and Year = "SO"
b.
select avg(GPA)
from Students
where Year = "FR" and Year = "SO"
c.
select sum(GPA)
from Students
where Year = "FR" or Year = "SO"
d.
select avg(GPA)
from Students
where Year = "FR" or Year = "SO"
Solutions to Additional Questions for Lab 14
1. The answer is (a). Option (b) does NOT create a table since primary key field is missing.
2. The answer is (d). The second query will fail because num will not be a unique entry.
3. The answer is (a) Since it is the only column with unique entries in it.
4. The answer is (b). Option (a) has a typo in it.
5. The answer is (c). Count (Distinct …) does not take into account the NULL value.
6. The answer is (a). SQL COUNT function does not take into account the NULL value.
7. The answer is (b). SQL MIN function does not take into account the NULL value.
8. The answer is (c). Other choices have syntax errors.
9. The answer is (b).