Question.1 SELECT last_name,
salary, hire_date FROM EMPLOYEES ORDER BY salary DESC
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
a. The two statements produce identical results
b. The second statement returns an error
c. There is no need to specify DESC because the results are sorted in descending order by default
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
a. The two statements produce identical results
b. The second statement returns an error
c. There is no need to specify DESC because the results are sorted in descending order by default
Question
2. Which of the following is not a numeric group function?
a. Avg
b. Count
c. Highest
d. Max
e. Stdev
f. Sum
Question
3. Examine the data in the EMPLOYEES table given below:
ALLEN
10
3000
MILLER 20 1500
KING 20 2200
DAVIS 30 5000
MILLER 20 1500
KING 20 2200
DAVIS 30 5000
Which of the following Subqueries
work?
a. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
a. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
b. SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
c. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
d. SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
e. SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
Question4. Which SQL
statement is used to extract data from a database?
a. GET
b. OPEN
c. EXTRACT
d. QUERY
Question
5.Which of the following statements are true?
a. With DDL you can create and remove tables, schemas, domains, indexes and views
b. Select, Insert and Update are DCL commands
c. Grant and Revoke are DML commands
d. Commit and Rollback are DCL commands
Question
6.Which of the following clauses are not allowed in a single row sub-query?
a. From
b. Where
c. Group by
d. Having
e. Order by
Question 7.
Which SQL statement is used to update data in a database?
a) UPDATE
b) SAVE AS
c) MODIFY
d) SAVE
Question 8. Which SQL statement is used to delete data from a database?
a) TRUNCATE
b) DELETE
c) REMOVE
Question 9. Which SQL statement is used to insert new data in a database?
a) ADD RECORD
b) ADD INTO
c) INSERT
d) ADD NEW
Question 10. With SQL, how do you select a column named “FirstName” from a table named “Persons” ?
a) EXTRACT FirstName FROM Persons
b) SELECT FirstName FROM Persons
c) SELECT Person.FirstName
Question 11. With SQL, how do you select all the columns from a tab!
a) SELECT [all] FROM Persons
b) SELECT All Persons
c) SELECT *Persons
d) SELECT *FROMPersons
Question 12. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Peter” ?
a) SELECT [all] FROM Persons WHERE FirstName=’Peter’
b) SELECT *FROM Persons WHERE FirstName LIKE ‘Peter’
c) SELECT [all] FROM Persons WHERE FirstName LIKE’Peter’
d) SELECT *FROMPersons WHERE FirstName=’Peter’
Question 13. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” stars with an “a” ?
a)SELECT *FROM Persons WHERE FirstName =’%%’
b) SELECT *FROM Persons WHERE FirstName LIKE ‘%a’
c) SELECT *FROM Persons WHERE FirstName =’a’
d) SELECT *FROM Persons WHERE FirstName LIKE ‘a%’
e) SELECT *FROM Persons WHERE FirstName =’a’
Question 14. The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true
a) True
b) False
Question 15. With SQL, how do you select all the records from a table named “Persons” where the “FirstName” is “Peter” and the “LastName” is “Jackson” ?
a)SELECT *FROM Persons WHERE FirstName LIKE ‘Peter’ And LastName LIKE ‘Jackson’
b) SELECT *FROM Persons WHERE FirstName =’Peter’ AND LastName=’Jackson’
c) SELECT FirstName=’Peter’, LastName=’Jackson’ FROM Persons
Question
16.What is the collection of information
stored in a database at a particular moment called?
a. Schema
b. Instance
c. Table
d. Cluster
e. View
f. Index
Question
17.The overall logical structure of a database can be expressed graphically by:
a. Data Flow Chart
b. Flow Chart
c. Directed Chart
d. Entity-Relationship Diagram (Answer)
e. None of the above
Question
18 .Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
--------
AuthorId
AuthorName
Country
What is the query to determine which German
books(if any) are more popular than all the French?
a. elect bookname from books where language=’German’ and popularityrating = (select popularityrating from books where language=’French’)
a. elect bookname from books where language=’German’ and popularityrating = (select popularityrating from books where language=’French’)
b. select bookname from books where language=’German’ and popularityrating> (select popularityrating from books where language=’French’)
c. select bookname from books where language=’French’ and popularityrating> (select max(popularityrating) from books where language=’German’)
d. select bookname from books where language=’German’ and popularityrating> (select max(popularityrating) from books where language=’French’)
Question
19.Which statements are true for views?
a. The definition of a view is stored in data dictionary
b. Views provide a more secure way of retrieving data
c. Views are actually Tables and store data in the same manner as Tables
d. All of the above
Question
20.Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have written books on two or more subjects?
a. select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId having count(*)>1)
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have written books on two or more subjects?
a. select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId having count(*)>1)
b. select AuthorName from Authors where BookId in (select BookId from Books group by BookId having count(*)>1)
c. select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId,Authorid having count(*)>1)
d. select AuthorName from Authors where Authorid in (select Authorid from Books group by Authorid having count(*)>1)
Question
21.What does the term DDL stand for?
a. Data Description Language
b. Dynamic Data Language
c. Data Definition Language
d. Data Derived Language
e. Descriptive Data Language
Question
22.The concept of data independence is similar to the concept of ________
a. Data type
b. Abstract data type
c. Consolidation
d.Isolation
Question
23.What are the programs that execute automatically whenever DML operations are
performed on tables called?
a. Triggers
b. Procedures
c. Functions
d. None of the above
Question
24.What clause should be used to display the rows of a table in ascending order
of a particular column?
a. Where
b. Order By
c. Group By
d. Having
e. First Group By and then Having
f. Like
g. Between
Question
25.What is the error in the following query if the Students table contains
several records?
SELECT name FROM students WHERE name =
(SELECT name FROM students ORDER BY name);
a. = should be replace by in operator (Answer)
b. Order by clause in the subquery should be preceded with a group by clause
c. Order by clause in the subquery can be used only if the where and group by clauses have been applied
d. Group by clause should be applied to the outer query
e. An order by clause is not allowed in a subquery (Answer)
f. There is no error
(SELECT name FROM students ORDER BY name);
a. = should be replace by in operator (Answer)
b. Order by clause in the subquery should be preceded with a group by clause
c. Order by clause in the subquery can be used only if the where and group by clauses have been applied
d. Group by clause should be applied to the outer query
e. An order by clause is not allowed in a subquery (Answer)
f. There is no error
Question
26.How can data be accessed by users who do not have direct access to the
tables?
a. By creating views (Answer)
b. By creating triggers
c. By creating stored procedures
d. None of the above
Question
27.Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languagе (such AS French, English, German etc)
Subjects
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
---------
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
--------
AuthorId
AuthorName
Country
What is the query to determine which Authors have
written at least 1 book with a popularity rating of less than 5?
a. select authorname from authors where authorid in (select authorid from books where popularityrating<5) (Answer)
b. select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
c. select authorname from authors where authorid in (select BookId from books where popularityrating<5)
d.select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))
a. select authorname from authors where authorid in (select authorid from books where popularityrating<5) (Answer)
b. select authorname from authors where authorid in (select authorid from books where popularityrating<=5)
c. select authorname from authors where authorid in (select BookId from books where popularityrating<5)
d.select authorname from authors where authorid in (select authorid from books where popularityrating in (0,5))
Question
28.
An
RDBMS performs the following steps:
1)It calculates the results of the group functions of each group
2)It groups those rows together based on the group by clause
3)It orders the groups based on the results of the group functions in the order by clause
4)It chooses and eliminates groups based on the having clause
5)It chooses rows based on the where clause
Arrange the above steps in the correct order of execution:
1)It calculates the results of the group functions of each group
2)It groups those rows together based on the group by clause
3)It orders the groups based on the results of the group functions in the order by clause
4)It chooses and eliminates groups based on the having clause
5)It chooses rows based on the where clause
Arrange the above steps in the correct order of execution:
a. 4,3,5,1,2
b. 4,5,3,2,1
c. 5,2,1,4,3 (Answer)
d. 5,2,3,4,1
e. 2,3,1,4,5
f. 2,3,1,5,4
g. 1,2,3,4,5
h. 3,2,1,4,5
Question
29.
_________
is the operation that displays certain columns from the table.
a. Restriction
b. Intersection
c. Join
d. Union
e. Projection
f. Selection (Answer)
g. Extraction
h. SubQuery
Question
30.There is a column c1 in the table t to which a primary key pk is to be
added. What will be the correct syntax?
a. Alter table t add primary key(c1); (Answer)
b. Alter table t add constraint pk primary key(c1);
c. Alter table t add (constraint pk primary key(c1));
d. Alter table t add pk constraint primary key(c1);
Question
31.Which of the following are aggregate functions in SQL?
a. Avg (Answer)
b. Select
c. Order By
d. Sum (Answer)
e. Union
f. Group by
g. Having
Question
32.A table Students has a column called name which stores the names of the
students. What will be the correct query to display the names of the students
in reverse order?
a. Select name from students reverse;
b. Select name from students reverse name;
c. Select name from students order by name descending;
d.Select name from students order by name reverse;
e.Select name from students order by name desc; (Answer)
f. Select desc name from students;
g. Select reverse name from students;
Question
33.The primary key index does not allow ________ data in a field.
a. Numeric
b. Character
c. Date
d. Null (Answer)
e. Duplicate (Answer)
f. All of the above
Question 34.
With SQL, how do you select all the records from a table named “Persons” where
the “LastName” is alphabetically between (and including) “Hansen” and
“Pettersen” ?
a. SELECT LastName>’Hansen’ AND LastName<’Pettersen’ FROM Persons
b. SELECT *FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’c. SELECT *FROM Persons WHERE LastName>’Hansen’ AND LastName<’Pettersen’
Question 35. With SQL statement is used to return only different values?
a. SELECT UNIQUE
b. SELECT IDENTITY
c. SELECT DIFFERENT
d. SELECT DISTINCT
Question 36. Which SQL Keyword is used to sort the result-set?
a. SORT BY
b. ORDER
c. ORDER BYd. SORT
Question 37. With SQL, how can you return all the records from a table named “Persons” stored descending by “FirstName” ?
a. SELECT *FROM Persons SORT BY ‘FirsttName’ DESC
b. SELECT *FROM Persons ORDER BY FirsttName DESC
c. SELECT *FROM Persons ORDER FirstName DESC
d. SELECT *FROM Persons SORT ‘FirsttName’ DESC
Question 38. With SQL, how can you insert a new record into the “Persons” table ?
a. INSERT INTO Persons VALUES (‘Jimmy’,'Jackson’)
b. INSERT (‘Jimmy’,'Jackson’) INTO Persons
c. INSERT VALUES (‘Jimmy’,'Jackson’) INTO Persons
Question 39. With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?
a. INSERT INTO Persons (LastName) VALUES (‘Olsen’)
b. INSERT (‘Olsen’) INTO Persons (LastName)
c. INSERT INTO Persons (‘Olsen’) INTO LastName
Question 40. How can you change “Nanson” into “Nilsen” in the “LastName” coloumn in the Persons table ?
a. UPDATE Persons SETLastName=’Hansen’ INTO LastName=’Nilsen’
b. UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’c. MODIFY Persons SET LastName=’Hansen’ INTO LastName=’Nilsen’
d. MODIFY Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
Question 41. With SQL, how can you delete the records where the “FirstName” is the “Peter” in the Persons Table?
a. DELETE FROM Persons WHERE FirstName =’Peter’
b. DELETE ROW FirstName=’Peter’ FROM Persons
c. DELETE FirstName=’Peter’ FROM Persons
Question 42. With SQL, how can you return the number of records in the “Persons”Table?
a. SELECT COLUMNS() FROM Persons
b. SELECT COUNT(*) FROM Personsc. SELECT COLUMNS(*) FROM Persons
d. SELECT COUNT() FROM Persons
Question 43. Given an employees table as follows: empid name managerid a1 bob NULL b1 jim a1 B2 tom a1 What value will select count(*) from employees return?
a. 1
b. 2
c. 3
d. none of the above
Question 44. The result of a SELECT statement can contain duplicate rows.
a. True
b. False
Question 45. Sometimes the expression “select count(*)” will return fewer rows than the expression “select count(value)”.
a. True
b. False
Question 46. What type of lock will deny users any access to a table?
a. EXPLICIT
b. IMPLICIT
c. EXCLUSIVE
d. SHARED
e. READ ONLY
Question 47. Which of the following is the correct SQL statement to use to remove rows from a table?
a. DROP
b. REMOVE ROW
c. DELETE
d. DELETE ROW
Question 48. The only way to join two tables is by using standard, ANSI syntax.
a. True
b. False
Question 49. A
NULL value is treated as a blank or 0
a. True
b. False
Question 50. The left outer join is one type of outer join. Another one is the.
a. right
b. full
c. right outer
d. full outer
e. all of the above
No comments:
Post a Comment