SQL Test1
SQL Test1
A Insert
B Grant
C Delete
D Update
E Revoke
F Commit
G Rollback
A Set transaction
B Explain plan
C Update
D Grant
E Insert
F Create
G Alter
H Revoke
4. Which of the following statements are not true regarding the primary key?
ALLEN 10 3000
MILLER 20 1500
KING 20 2200
DAVIS 30 5000
Which of the following Subqueries work?
ASELECT * 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));
8. Examine the description of the STUDENTS table:
STD_ID NUMBER (4)
COURSE_ID VARCHAR2 (10)
START_DATE DATE
END_DATE DATE
The aggregate functions valid on the START_DATE column are:
ASUM(start_date)
B AVG(start_date)
C COUNT(start_date)
D AVG(start_date, end_date)
E MIN(start_date)
11. Which component of an RDBMS validates the syntax of the user's query?
A Query Parser
B The Database Manager
C Query Optimization
D Database Administrator
A Restriction
B Extraction
C Projection
D Intersection
E Union
F Minus
15. 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?
16. What items, other than column names can be included in the select clause?
A Arithmetic expressions
B Column aliases
C Concatenated columns
20. The level of data abstraction which describes how the data is actually stored is?
A Physical level
B Conceptual level
C Storage level
D File level
27. The names of those departments where there are more than 100 employees have to be
displayed. Given two relations, employees and departments, what query should be used?
Employee
---------
Empno
Employeename
Salary
Deptno
Department
---------
Deptno
Departname
A Select departname from department where deptno in (select deptno from employee group by
deptno having count(*) > 100);
B Select departname from department where deptno in (select count(*) from employee group
by deptno where count(*) > 100);
C Select departname from department where count(deptno) > 100;
D Select departname from department where deptno in (select count(*) from employee where
count(*) > 100);
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine the names of the Authors who have written more than 1 book?
A select AuthorName from Authors where AuthorId in (select AuthorId from Books group by
AuthorId having count(*)>1)
B select AuthorName from Authors, Books where Authors.AuthorId=Books.AuthorId and
count(BookId)>1
C select AuthorName from Authors, Books where Authors.AuthorId=Books.AuthorId group by
AuthorName having count(*)>1
D select AuthorName from Authors where AuthorId in (select AuthorId from Books having
count(BookId)>1)
31. When a table is dropped using a simple DROP statement, SQL performs some more operations
simultaneously, select all the valid operations?
33. A production house has two sales outlets. Both outlets are maintaining their data separately in
schemas A and B respectively. The Management wants to see the sale of both outlets in one
report. Both outlets are using tables called Sales which have identical structure. Which method
you will adopt to create the report?
34. 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
35. Which of the following is not a type of constraint?
A Primary key
B Unique
C Check
D Distinct
E Default
36. Consider the query:
SELECT name
FROM Student
WHERE name LIKE '_a%';
Which names will be displayed?
38. Which character function should be used to return a specified portion of a character string?
A CONCAT
B LENGTH
C SUBSTR
D INITCAP
39. What will happen if you query the emp table as shown below:
select empno, DISTINCT ename, Salary from emp;
Which of the following statements finds the highest Grade Point Average (GPA) per semester?
A Round
B Floor
C Avg
D Sqrt
E Tan
43. 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:
A 4,3,5,1,2
B 4,5,3,2,1
C 5,2,1,4,3
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
44. Data validation can be implemented at the data definition stage through:
A Where
B Order By
C Group By
D Having
E First Group By and then Having
F Like
G Between
46. What is the error in the following query if the Students table contains several records?
C Order by clause in the subquery can be used only if the where and group by clauses have been
applied
F There is no error
What will happen if all the parentheses are removed from the calculation?
A4
B2
C1
D .5
E .25
F0
G8
H 24
51. Where should sub queries be used?
A To define the set of rows to be inserted in a table
B To define the set of rows to be included in a view
C To define one or more values to be assigned to existing rows
D To provide values for conditions in the Where clause
E To define a table to be operated on by a containing query
F All of the above are correct
G None of the above is correct
52. In which sequence are queries and sub-queries executed by the SQL Engine?
A primary query -> sub query -> sub sub query and so on
B sub sub query -> sub query -> prime query
C the whole query is interpreted at one time
D there is no fixed sequence of interpretation, the query parser takes a decision on the fly
53. Are both the statements correct?
(a)where deptno in(2,4,5)
(b)where deptno=2 or deptno=4 or deptno=5
A True
B False
54. What is the correct order of clauses in the select statement?
1 select
2 order by
3 where
4 having
5 group by
A 1,2,3,4,5
B 1,3,5,4,2
C 1,3,5,2,4
D 1,3,2,5,4
E 1,3,2,4,5
F 1,5,2,3,4
G 1,4,2,3,5
H 1,4,3,2,5
55. There are two tables A and B. You are retreiving data from both tables where all rows from B
table and only matching rows from A table should be displayed. Which type of join you will
apply between A and B tables?
A Inner join
B Left outer join
C Right outer join
D Self join
56. Point out the incorrect statement regarding group functions:
A Group functions act on a group of rows
B Group functions return one result for all the rows operated upon
C Group functions ignore the null values
D Stdev and variance are examples of group functions
E One cannot combine group and single value functions in a query
F Sum is not a group function
57. How many foreign key constraints can a table have?
A1
B2
C3
D4
E5
F6
G None of these above
58. Which statement is correct for FIRST NORMAL FORM?
A Includes only tables that do not have composite primary keys
B Must have data stored in a two-dimensional table with no repeating groups
C Every non-key column is nontransitively dependent upon its primary key
D None of these above
59. What is wrong with the following query:
select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
A In the sub query, '*' should be used instead of 'OrderID'
B The sub query can return more than one row, so, '=' should be replaced with 'in'
C The sub query should not be in parenthesis
D None of these above
60. A company has the following departments:
Marketing , Designing , Production , Packing
What will be the result of the following query?
select * from table where department < 'Marketing';
A The query will return " Designing , Packing "
B The query will return " Designing , production ,Packing "
C The query will return "Packing"
D Strings cannot be compared using < operator
E The query will return " Designing "
61. Which of the following is not a numeric group function?
A Avg
B Count
C Highest
D Max
E Stdev
F Sum
62. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which German books(if any) are more popular than all the
French?
select 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')
63. Consider the following tables:
Books
------
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book on a scale of 1 to 10)
Language (such as French, English, German etc)
Subjects
---------
SubjectId
Subject (such as History, Geography, Mathematics etc)
Authors
--------
AuthorId
AuthorName
Country
What is the query to determine which is the most popular book written in French?
A Primary key
B Foreign key
C Not null
D Check
E Unique
65. A construction company is currently executing three projects- hotel construction, residential
construction and business towers. The construction company employs both Civil Engineers and
Structural Engineers. A Civil Engineer can work on only one project at a time, but each project
can accomodate more than one Civil Engineer. On the other hand, a Structural Engineer can
work on more than one project and a project could accomodate several Structural Engineers.
Define the nature of relationship between (Civil Engineers and Projects) and (Structural
Engineers and Projects)
A Dominant entity
B Subordinate entity
C Primary entity
D Secondary entity
Examine the code given below:
67. SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000
Which of the following statements is correct with regard to this code?
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