0% found this document useful (0 votes)
8 views

MORE_SQL_2024

Uploaded by

soduro849
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

MORE_SQL_2024

Uploaded by

soduro849
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 95

1. The query given below will give an error.

Which one of the following has to be


replaced to get the desired output?

SELECT ID, name FROM 1_Order WHERE instructor=1;


a) _Order
b) 2Order
c) 3Order
d) Instructor
View Answer

Answer: a
Explanation: Table name should not start with numerical value as per naming
convention in T-SQL.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate
Now!
advertisement

2. The following query can be replaced by which one of the following?

SELECT name, course_id


FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a)

Check this: Programming MCQs | Information Technology Books


SELECT name,course_id
FROM teaches,instructor
WHERE instructor_id=course_id;
b)

SELECT name, course_id


FROM instructor NATURAL JOIN teaches;
c)

SELECT name ,course_id


FROM instructor;
d)

SELECT course_id
FROM instructor JOIN teaches;
View Answer
Answer: b
Explanation: Join clause joins two tables by matching the common column.

3. Select * from employee where salary>10000 and dept_id=101;


Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
View Answer

Answer: d
Explanation: Here * is used to select all the fields of the relation.
4. Which of the following statements contains an error?
a)

SELECT * FROM emp


WHERE empid = 10003;
b)

SELECT empid
FROM emp
WHERE empid = 10006;
c) Select empid from emp;
d)

SELECT empid
WHERE empid = 1009 AND lastname = ‘GELLER’;
View Answer
Answer: d
Explanation: This query do not have from clause which specifies the relation from
which the values has to be selected.

5. Insert into employee _________ (1002,Joey,2000);


In the given query which of the keyword has to be inserted?
a) Table
b) Values
c) Relation
d) Field
View Answer

Answer: b
Explanation: Value keyword has to be used to insert the values into the table.
6. To delete a database ___________ command is used.
a) Delete database database_name
b) Delete database_name
c) drop database database_name
d) drop database_name
View Answer

Answer: c
Explanation: This will delete the database with its structure.
7. The ________________ is essentially used to search for patterns in target
string.
a) Like Predicate
b) Null Predicate
c) In Predicate
d) Out Predicate
View Answer

Answer: a
Explanation: Like matches the pattern with the query.
8. Which is a duplicate copy of a file program that is stored on a different
storage media than the original location?
a) Concurrency
b) Deadlock
c) Backup
d) Recovery
View Answer

Answer: c
Explanation: Backup is required to protect the data.
9. _______________ joins are SQL server default.
a) Outer
b) Inner
c) Equi
d) None of the Mentioned
View Answer

Answer: b
Explanation: Inner query joins only the rows that are matching.
10. To alter a database ___________ command is used.
a) ALTER database database_name
b) ALTER database_name
c) ALTER database database_name
d) ALTER database_name
View Answer

Answer: c
Explanation: ALTER Statement will alter the database structure and its related
functionalities.

Q.
Which of the following is an aggregate function in SQL?
A. Union
B. Like
C. Group By
D. Max
Answer D

Which of the following is a SQL aggregate function?


A. LEFT

B. AVG

C. JOIN

D. LEN

Answer: Option B

Sql Server Database Engine processes select statement in a logical manner.choose


the best answer that
describes the correct Logical Query Processing Order
Select,Order By,Where,Group By,Having,From
From ,Select,Where,Group By,Having,Order By
From,Where,Group By,Having,Select,Order By
From,Where,Group By,Select,Having,Order By
Answer: Option D

What is the use of self join in SQL?Choose the best answer


It is useful when you want to correlate pairs of rows from the same table, for
example a parent - child relationship. The following query returns the names of all
immediate subcategories of the category 'Kitchen'.

SELECT T2.name
FROM
category T1JOIN category T2
ON
T2.parent = T1.id
WHERE
T1.name = 'Kitchen'

1. Aggregate functions are functions that take a ___________ as input and return a
single value.
a) Collection of values
b) Single value
c) Aggregate value
d) Both Collection of values & Single value
View Answer

Answer: a
Explanation: None.
2.

SELECT __________
FROM instructor
WHERE dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)
View Answer B

Note: Join free Sanfoundry classes at Telegram or Youtube


advertisement

3.

Take Database Management System Tests Now!


SELECT COUNT (____ ID)
FROM teaches
WHERE semester = ’Spring’ AND YEAR = 2010;
If we do want to eliminate duplicates, we use the keyword ______in the aggregate
expression.
a) Distinct
b) Count
c) Avg
d) Primary key
View Answer

4. All aggregate functions except _____ ignore null values in their input
collection.
a) Count(attribute)
b) Count(*)
c) Avg
d) Sum
View Answer

Answer: b
Explanation: * is used to select all values including null.
5. A Boolean data type that can take values true, false, and________
a) 1
b) 0
c) Null
d) Unknown
View Answer

Answer: d
Explanation: Unknown values do not take null value but it is not known.
6. The ____ connective tests for set membership, where the set is a collection of
values produced by a select clause. The ____ connective tests for the absence of
set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or
View Answer

Answer: c
Explanation: In checks, if the query has the value but not in checks if it does not
have the value.
7. Which of the following should be used to find all the courses taught in the Fall
2009 semester but not in the Spring 2010 semester .
a)

SELECT DISTINCT course id


FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009 AND
course id NOT IN (SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
b)

SELECT DISTINCT course_id


FROM instructor
WHERE name NOT IN (’Fall’, ’Spring’);
c)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
d)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT course id, sec id, semester,
YEAR
FROM teaches
WHERE teaches.ID= 10101);
View Answer
Answer: a
Explanation: None.

8. The phrase “greater than at least one” is represented in SQL by _____


a) < all
b) < some
c) > all
d) > some
View Answer

Answer: d
Explanation: >some takes atlest one value above it .
9. Which of the following is used to find all courses taught in both the Fall 2009
semester and in the Spring 2010 semester .
a)

SELECT course id
FROM SECTION AS S
WHERE semester = ’Fall’ AND YEAR= 2009 AND
EXISTS (SELECT *
FROM SECTION AS T
WHERE semester = ’Spring’ AND YEAR= 2010 AND
S.course id= T.course id);
b)

SELECT name
FROM instructor
WHERE salary > SOME (SELECT salary
FROM instructor
WHERE dept name = ’Biology’);
c)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT course id, sec id, semester,
YEAR
FROM teaches
WHERE teaches.ID= 10101);
d)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
View Answer
Answer: a
Explanation: None.

10. We can test for the nonexistence of tuples in a subquery by using the _____
construct.
a) Not exist
b) Not exists
c) Exists
d) Exist
View Answer

Answer: b

The ____ connective tests for set membership, where the set is a collection
of values produced by a select clause. The ____ connective tests for the absence of
set membership.
A. In, not in
B. In, or
C. Not in, in
D. Or, in
Answer A

List all the SQL server editions


Main: Enterprise, Standard, Business Intelligence, Azure SQL Database

Other: Developer, Express, Compact

What are the limitations of Express edition?


Only 1GB memory per instance, 10GB storage per database
Which version of SQL includes all features, including business intelligence, data
warehousing, & high availability?
Enterprise

You have founded a new company with two friends. Your new application (app) uses a
SQL Server database to store information. You are unsure whether your app will be
successful but, if it is, you will need both high performance and space for large
volumes of data. However, you have not yet launched, so are unsure how many people
will use your app. Which edition of SQL Server should you use for this system?

1) Azure SQL Database

2) Enterprise edition

3) Express edition

4) Business Intelligence edition

5) Any edition is appropriate for these requirements


1) Azure SQL Database

This version allows you to start small, and scale up as required. As a startup,
using Azure SQL Database also means you do not need to buy server hardware to run
SQL Server. Because Azure SQL Database is Software as a Service (SaaS), you pay for
what you use, without high upfront costs.

Which authentication methods do you use to log onto SQL server?


Either Windows Auth or SQL Server Auth

A colleague has asked you to run some test queries against the company's scheduling
database. Administrators have given you the name of the server where the database
is hosted, and the name of the database. Permissions to run the necessary queries
have been granted to your Active Directory® account. You are logged on to a client
computer with this Active Directory account and have started SQL Server Management
Studio. What other information do you need to connect to the database?

1) Your Active Directory account username.

2) Your Active Directory account password.

3) The name of the login created for you in the SQL Server instance.

4) The name of the instance that hosts the database.

5) The name of the user created for you in the SQL Server database.
4) The name of the instance that hosts the database.

You do not need to provide your Active Directory credentials because these will be
sent to SQL Server automatically when you connect. This account has been associated
with a login and user in SQL Server by database administrators when they granted
access to your account. However, unless the database is on the default instance,
you must specify which instance to connect to.
Can a SQL Server database be stored across multiple instances?
No. A database is completely contained within a single instance.

What does a SQL Server Management Studio solution contain?


SSMS allows you to organize SQL Scripts so that you can manage large collections of
files. Projects can contain scripts, connection strings and other settings.
Solutions are collections of projects.

You have the following T-SQL query:

SELECT HumanResources.Employees.ID, HumanResources.Employers.ID AS CompanyID,

HumanResources.Employees.Name, HumanResources.Employers.Name AS CompanyName

FROM HumanResources.Employees

JOIN HumanResources.Employers

ON HumanResources.Employees.EmployerID = HumanResources.Employers.ID;

How can you improve the readability of this query?


Use AS to create more readable aliases for the Employees and Employers tables.

Always remember to consider the readability of T-SQL queries because clear queries
can help to avoid coding mistakes and bugs.

inner join
Only returns matched records from the tables that are being joined

outer join
A join in which rows that do not have matching values in common columns are
nevertheless included in the result table.

cross join
A join in which each row from one table is combined with each row from another
table.

You have a table named PoolCars and a table named Bookings in your
ResourcesScheduling database. You want to return all the pool cars for which there
are zero bookings. Which of the following queries should you use?

1) SELECT pc.ID, pc.Make, pc.Model, pc.LicensePlate

FROM ResourcesScheduling.PoolCars AS pc, ResourcesScheduling.Bookings AS b

WHERE pc.ID = b.CarID;

--

2) SELECT pc.ID, pc.Make, pc.Model, pc.LicensePlate

FROM ResourcesScheduling.PoolCars AS pc
RIGHT OUTER JOIN ResourcesScheduling.Bookings AS b

ON pc.ID = b.CarID;

--

3) SELECT pc.ID, pc.Make, pc.Model, pc.LicensePlate

FROM ResourcesScheduling.PoolCars AS pc

JOIN ResourcesScheduling.Bookings AS b

ON pc.ID = b.CarID;

--

4) SELECT pc.ID, pc.Make, pc.Model, pc.LicensePlate

FROM ResourcesScheduling.PoolCars AS pc

LEFT OUTER JOIN ResourcesScheduling.Bookings AS b

ON pc.ID = b.CarID

WHERE b.BookingID IS NULL;


4) LEFT OUTER Join

If a pool car has no bookings, there will be no rows in the Bookings table for that
matching CarID. When you perform a LEFT OUTER JOIN for Bookings to PoolCars, your
results include all cars and all bookings for those cars. Because it is a LEFT
JOIN, all cars are included even if they have no bookings. Those records, in the
result set, have null values for the BookingID. By testing for these null values in
the WHERE clause, you can filter out all cars with bookings and leave only those
cars with no bookings.

SELF JOIN example


SELECT e.empid ,e.lastname AS empname,e.title,e.mgrid, m.lastname AS mgrname
FROM HR.Employees AS e
LEFT OUTER JOIN HR.Employees AS m
ON e.mgrid=m.empid;

You have two tables named FirstNames and LastNames. You want to generate a set of
fictitious full names from this data. There are 150 entries in the FirstNames table
and 250 entries in the LastNames table. You use the following query:

SELECT (f.Name + ' ' + l.Name) AS FullName

FROM FirstNames AS f

CROSS JOIN LastNames AS l

How many fictitious full names will be returned by this query?


37,500 names. The CROSS JOIN returns a Cartesian product of the entries in the
FirstNames and LastNames tables—150 x 250 = 37,500.

How does an inner join differ from an outer join?


inner = only matching rows. outer includes all rows from both tables and includes
NULLS for rows where no match is found

Which join types include a logical Cartesian product?


inner, outer, cross

Can a table be joined to itself?


yes, as a self join. but you have to use an alias for at least one of the mentions
of the table in the FROM clause

You have a table named Sales with the following columns: Country, NumberOfReps,
TotalSales.You want to find out the average amount of sales a sales representative
makes in each country. What SELECT query could you use?
SELECT Country, (TotalSales / NumberOfReps) AS AverageSalesPerRep

FROM Sales;

You can use a calculation from two columns in the Sales table to determine the
average amount of sales per representative.

you have company departments in five countries. You have the following query for
the Human Resources database:

SELECT DeptName, Country

FROM HumanResources.Departments

This returns:

DeptName Country

--------- --------

Sales UK

Sales USA

Sales France

Sales Japan

Marketing USA

Marketing Japan

Research USA

How many rows are returned?


7. SELECT DISTINCT queries return all unique rows. Sales in the UK is therefore
considered distinct from Sales in the USA, France, and Japan. In fact, the DISTINCT
keyword makes no difference to the results for this query.

Which of the following statements use correct column aliases? (select all that
apply)
1.

SELECT Name AS ProductName FROM Production.Product

2.

SELECT Name = ProductName FROM Production.Product

3.

SELECT ProductName == Name FROM Production.Product

4.

SELECT ProductName = Name FROM Production.Product

5.

SELECT Name AS Product Name FROM Production.Product


Statements 1 and 4 are correct.

Statement 1 correctly uses the AS alias.

Statement 2 is trying to assign the alias name to the column, which is incorrect.

Statement 3 uses the double equals sign, which is not correct syntax in the T-SQL
programming language.

Statement 4 correctly assigns the Name column to the ProductName alias.

Statement 5 is almost correct. However, there is a space between the two words in
the alias, which will work if it is corrected to be [Product Name] or 'Product
Name'.

You have the following query:

SELECT FirstName LastName

FROM HumanResources.Employees;

You are surprised to find that the query returns the following:

LastName

---------

Fred

Rosalind

Anil

Linda

What error have you made in the SELECT query?


forgot a comma. need to do:
select firstname, lastname
from hr.employees

You have the following SELECT query:

SELECT FirstName, LastName, Sex

FROM HumanResources.Employees;

This returns:

FirstName LastName Sex

---------- --------- ----

Maya Steele 1

Adam Brookes 0

Naomi Sharp 1

Pedro Fielder 0

Zachary Parsons 0

How could you make these results clearer?


a CASE statement:

select firstname, lastname,


CASE sex
WHEN 1 THEN 'Female'
WHEN 0 THEN 'Male'
ELSE 'unspecified'
END
From hr.Employees;

Why is the use of SELECT * not a recommended practice?


resource-intensive

1) * asks for all columns, which is typically too much.

2) Query is exposed to changes in the underlying table structure and could return
unexpected results.

From the following T-SQL elements, select the one that does not contain an
expression:

1) SELECT FirstName, LastName, SkillName AS Skill, GetDate() - DOB AS Age

2) WHERE HumanResources.Department.ModifiedDate > (SYSDATETIME() - 31)

3) JOIN HumanResources.Skills ON Employees.ID = Skills.EmployeeID

4) WHERE Skill.Level + Skill.Confidence > 10


3.
An expression is a combination of identifiers, symbols, and operators that return a
single result. The only element that does not contain a symbol and an operator is
Option 3.

SQL expression
A formula or set of values that determines the exact results of an SQL query.

examples: >, <>, <=, -, +

From the following T-SQL elements, select the one that can include a predicate:

WHERE clauses

JOIN conditions

HAVING clauses

WHILE statements

All of the above


all of the above.

WHERE clauses use predicates to determine which rows to return. JOIN conditions use
predicates to determine which rows from different tables to join into a single
result row. HAVING clauses use predicates to determine which groups to return.
WHILE statements use predicates to determine when to stop executing T-SQL
statements in a batch.

SQL Predicate
ALL, ANY, BETWEEN, IN, LIKE, OR, SOME

(module 2 - check your knowledge #4

Put the following T-SQL elements in order by numbering each to indicate the order
that SQL Server will process them in when they appear in a single SELECT statement.

GROUP BY

HAVING

FROM

WHERE

SELECT

ORDER BY
(this is the order in which SQL executes, not the order in which you write it)
A:
1) FROM
2) WHERE
3) GROUP BY
4) HAVING
5) SELECT
6) ORDER BY

Which category of T-SQL statements concerns querying and modifying data?


Data Manipulation Language (DML).

Data Manipulation Language (DML)


Commands that maintain and query a database

What are some examples of aggregate functions supported by T-SQL?


SUM, MIN, COUNT, COUNTBIG, MAX, AVG.

Aggregate functions are used in conjunction with a GROUP BY clause.

Which SELECT statement element will be processed before a WHERE clause?


FROM. The FROM clause is evaluated first to provide the source rows for the rest of
the statement.

what are the 5 system databases that SQL server comes with?
master: the system configuration database.

model: the template database. SQL Server will apply any changes made in model to
new databases.

msdb: used by SQL Server Agent to schedule jobs and alerts.

tempDb: a temporary store for data such as work tables. This database is dropped
and
recreated each time SQL Server restarts, which means that any temporary tables will
be lost when SQL Server closes down.

resource: a hidden, read-only database that contains all the system objects for
other databases.

1. Which is the subset of SQL commands used to manipulate Oracle Database


structures, including tables?
a) Data Definition Language(DDL)
b) Data Manipulation Language(DML)
c) DML and DDL
d) None of the Mentioned
View Answer
Answer: a
Explanation: The DDL is used to manage table and index structure.CREATE, ALTER,
RENAME, DROP and TRUNCATE statements are the names of few data definition elements.
2. Which of the following is/are the DDL statements?
a) Create
b) Drop
c) Alter
d) All of the Mentioned
View Answer

Answer: d
Explanation: All the mentioned commands are the part of DDL statements.
3. In SQL, which command(s) is(are) used to change a table’s storage
characteristics?
a) ALTER TABLE
b) MODIFY TABLE
c) CHANGE TABLE
d) All of the Mentioned
View Answer

Answer: a
Explanation: To change the structure of the table we use ALTER TABLE Syntax:
ALTER TABLE “table_name” ADD “column_name” datatype
OR
ALTER TABLE “table_name” DROP COLUMN “column_name”.
Subscribe Now: Oracle Database Newsletter | Important Subjects Newsletters
advertisement
4. In SQL, which of the following is not a data definition language commands?
a) RENAME
b) REVOKE
c) GRANT
d) UPDATE
View Answer

Answer: a
Explanation: With RENAME statement you can rename a table.RENAME, REVOKE and GRANT
are DDL commands and UPDATE is DML command.
5. ________clause is an additional filter that is applied to the result.
a) Select
b) Group-by
c) Having
d) Order by
View Answer

Answer: c
Explanation: The HAVING clause was added to SQL because the WHERE keyword could not
be used with aggregate functions.
Check this: Information Technology Books | Oracle Database Books
6. ___________ defines rules regarding the values allowed in columns and is the
standard mechanism for enforcing database integrity.
a) Column
b) Constraint
c) Index
d) Trigger
View Answer

Answer: b
Explanation: SQL constraints are used to specify rules for the data in a table.If
there is any violation between the constraint and the data action, the action is
aborted by the constraint.
7. SQL has how many main commands for DDL:
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: c
Explanation: Create, Delete, Alter these are 3 main command.
8. Which command defines its columns, integrity constraint in create table:
a) Create command
b) Drop table command
c) Alter table command
d) All of the Mentioned
View Answer

Answer: a
Explanation: The CREATE TABLE statement is used to create a table in a
database.Tables are organized into rows and columns.
9. Which command is used for removing a table and all its data from the database:
a) Create command
b) Drop table command
c) Alter table command
d) All of the Mentioned
View Answer

Answer: b
Explanation: The DROP INDEX statement is used to delete an index in a table.
10. Which command allows the removal of all rows from a table but flushes a table
more efficiently since no rollback information is retained:
a) TRUNCATE command
b) Create command
c) Drop table command
d) Alter table command
View Answer

Answer: a
Explanation: The SQL TRUNCATE TABLE command is used to delete complete data from an
existing
table.You can also use DROP TABLE command to delete complete table but it would
remove complete table structure
form the database and you would need to re-create this table once again if you wish
you store some data.

1. What type of join is needed when you wish to include rows that do not have
matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the Mentioned
View Answer

Answer: c
Explanation:OUTER JOIN is the only join which shows the unmatched rows.
2. What type of join is needed when you wish to return rows that do have matching
values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the Mentioned
View Answer

Answer: d
Explanation: Outer join returns the row having matching as well as non matching
values.
3. Which of the following is one of the basic approaches for joining tables?
a) Subqueries
b) Union Join
c) Natural join
d) All of the Mentioned
View Answer

Answer: d
Explanation: The SQL subquery is a SELECT query that is embedded in the main SELECT
statement. In many cases, a subquery can be used instead of a JOIN.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement

4. The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID,


ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T WHERE CUSTOMER_T.
CUSTOMER_ID = ORDER_T. CUSTOMER_ID?
a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join
View Answer

Answer: a
Explanation: Equi-join joins only same data entry field. For example, one table
contains department id and another table should contain department id.
5. A UNION query is which of the following?
a) Combines the output from no more than two queries and must include the same
number of columns
b) Combines the output from no more than two queries and does not include the same
number of columns
c) Combines the output from multiple queries and must include the same number of
columns
d) Combines the output from multiple queries and does not include the same number
of columns
View Answer

Answer: c
Explanation: A single UNION can combine only 2 sql query at a time.
Take SQL Server Tests Now!
6. Which of the following statements is true concerning subqueries?
a) Involves the use of an inner and outer query
b) Cannot return the same result as a query that is not a subquery
c) Does not start with the word SELECT
d) All of the mentioned
View Answer

Answer: a
Explanation: Subquery—also referred to as an inner query or inner select—is a
SELECT statement embedded within a data manipulation language (DML) statement or
nested within another subquery.
7. Which of the following is a correlated subquery?
a) Uses the result of an inner query to determine the processing of an outer query
b) Uses the result of an outer query to determine the processing of an inner query
c) Uses the result of an inner query to determine the processing of an inner query
d) Uses the result of an outer query to determine the processing of an outer query
View Answer

Answer: a
Explanation: A ‘correlated subquery’ is a term used for specific types of queries
in SQL in computer databases. It is a subquery (a query nested inside another
query) that uses values from the outer query in its WHERE clause.
8. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the Mentioned
View Answer

Answer: d
Explanation: Join can be used for more than one table. For ‘n’ tables the no of
join conditions required are ‘n-1’.
9. The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID,
ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T?
a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join
View Answer

Answer: d
Explanation: Cartesian Join is simply the joining of one or more table which
returns the product of all the rows in these tables.
10. Which is not a type of join in T-SQL?
a) Equi-join
b) Natural join
c) Outer join
d) Cartesian join
View Answer

Answer: b
Explanation: A NATURAL JOIN is an inner join where the RDBMS automatically selects
the
join columns based on common columns names. Some RDBMS
vendors, like Oracle but not SQL Server, implement a NATURAL JOIN operator.

1. The query given below will give an error. Which one of the following has to be
replaced to get the desired output?

SELECT ID, name FROM 1_Order WHERE instructor=1;


a) _Order
b) 2Order
c) 3Order
d) Instructor
View Answer

Answer: a
Explanation: Table name should not start with numerical value as per naming
convention in T-SQL.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate
Now!
advertisement

2. The following query can be replaced by which one of the following?

SELECT name, course_id


FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a)

Check this: Programming MCQs | Information Technology Books


SELECT name,course_id
FROM teaches,instructor
WHERE instructor_id=course_id;
b)

SELECT name, course_id


FROM instructor NATURAL JOIN teaches;
c)

SELECT name ,course_id


FROM instructor;
d)

SELECT course_id
FROM instructor JOIN teaches;
View Answer
Answer: b
Explanation: Join clause joins two tables by matching the common column.

3. Select * from employee where salary>10000 and dept_id=101;


Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
View Answer

Answer: d
Explanation: Here * is used to select all the fields of the relation.
4. Which of the following statements contains an error?
a)

SELECT * FROM emp


WHERE empid = 10003;
b)

SELECT empid
FROM emp
WHERE empid = 10006;
c) Select empid from emp;
d)

SELECT empid
WHERE empid = 1009 AND lastname = ‘GELLER’;
View Answer
Answer: d
Explanation: This query do not have from clause which specifies the relation from
which the values has to be selected.
5. Insert into employee _________ (1002,Joey,2000);
In the given query which of the keyword has to be inserted?
a) Table
b) Values
c) Relation
d) Field
View Answer

Answer: b
Explanation: Value keyword has to be used to insert the values into the table.
6. To delete a database ___________ command is used.
a) Delete database database_name
b) Delete database_name
c) drop database database_name
d) drop database_name
View Answer

Answer: c
Explanation: This will delete the database with its structure.
7. The ________________ is essentially used to search for patterns in target
string.
a) Like Predicate
b) Null Predicate
c) In Predicate
d) Out Predicate
View Answer

Answer: a
Explanation: Like matches the pattern with the query.
8. Which is a duplicate copy of a file program that is stored on a different
storage media than the original location?
a) Concurrency
b) Deadlock
c) Backup
d) Recovery
View Answer

Answer: c
Explanation: Backup is required to protect the data.
9. _______________ joins are SQL server default.
a) Outer
b) Inner
c) Equi
d) None of the Mentioned
View Answer

Answer: b
Explanation: Inner query joins only the rows that are matching.
10. To alter a database ___________ command is used.
a) ALTER database database_name
b) ALTER database_name
c) ALTER database database_name
d) ALTER database_name
View Answer

Answer: c
1. Is “GROUP BY” clause is similar to “ORDER BY” clause?
a) Yes
b) No
c) Depends
d) None of the mentioned
View Answer

Answer: b
Explanation: “ORDER BY” clause is used for sorting while “GROUP BY” clause is used
for aggregation of fields.
2. What is the meaning of “ORDER BY” clause in Mysql?
a) Sorting your result set using column data
b) Aggregation of fields
c) Sorting your result set using row data
d) None of the mentioned
View Answer

Answer: a
Explanation: None.
3. What is the significance of “ORDER BY” in the following MySQL statement?

Subscribe Now: MySQL Newsletter | Important Subjects Newsletters


advertisement

SELECT emp_id, fname, lname


FROM person
ORDER BY emp_id;
a) Data of emp_id will be sorted
b) Data of emp_id will be sorted in descending order
c) Data of emp_id will be sorted in ascending order
d) All of the mentioned
View Answer

Answer: a
Explanation: Sorting in ascending or descending order depends on keyword “DESC” and
“ASC”.
Participate in MySQL Certification Contest of the Month Now!
4. What will be the order of sorting in the following MySQL statement?

SELECT emp_id, emp_name


FROM person
ORDER BY emp_id, emp_name;
a) Sorting {emp_id, emp_name}
b) Sorting {emp_name, emp_id}
c) Sorting (emp_id} but not emp_name
d) None of the mentioned
View Answer

Answer: a
Explanation: In the query, first “emp_id” will be sorted then emp_name with respect
to emp_id.
5. If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the
output on execution of the following MySQL statement?

SELECT emp_id
FROM person
ORDER BY emp_id;
a) {1, 2, 3, 4, 6, 7, 9}
b) {2, 1, 4, 3, 7, 9, 6}
c) {9, 7, 6, 4, 3, 1, 2}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.
6. If emp_id contain the following set {1, 2, 3, 4, 1, 1}, what will be the output
on execution of the following MySQL statement?

SELECT emp_id
FROM person
ORDER BY emp_id;
a) {1, 1, 1, 2, 3, 4}
b) {1, 2, 3, 4, 1, 1}
c) {1, 1, 2, 3, 4, 1}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.
7. If emp_id contain the following set {1, 2, 2, 3, 3, 1}, what will be the output
on execution of the following MySQL statement?

SELECT emp_id
FROM person
ORDER BY emp_id;
a) {1, 1, 2, 2, 3, 3}
b) {1, 2, 3, 3, 2, 1}
c) {2, 2, 1, 1, 3, 3}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.
8. If emp_id contain the following set {-1, -2, 2, 3, -3, 1}, what will be the
output on execution of the following MySQL statement?

SELECT emp_id
FROM person
ORDER BY emp_id;
a) {-3, -2, -1, 1, 2, 3}
b) {-1, 1, -2, 2, -3, 3}
c) {1, 2, 3, -1, -2, -3}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.
9. Which keyword is used for sorting the data in descending order in Mysql?
a) DESC
b) ASC
c) ALTER
d) MODIFY
View Answer

Answer: a
Explanation: None.
10. Which keyword is used for sorting the data in ascending order in Mysql?
a) DESC
b) ASC
c) ALTER
d) MODIFY
View Answer

Answer: b
Explanation: None.

1. Which of the following is a large object data type?


a) varchar(max)
b) varbinary(max)
c) nvarchar(max)
d) image
View Answer

Answer: d
Explanation: In SQL Server, based on their storage characteristics, some data types
are designated as large value data types and large object data types.
2. Data types in SQL Server are organized into how many categories?
a) 6
b) 8
c) 9
d) 10
View Answer

Answer: a
Explanation: SQL Server offers six categories of data types for your use:-exact
numeric, Unicode character strings, approximate numeric, Binary strings, Date and
time and Character strings.
3. Exact Numeric data type is ___________
a) bigint
b) int
c) smallmoney
d) all of the mentioned
View Answer

Answer: d
Explanation: Exact numeric data types store numeric values where you wish to
specify the precision of the variable. They may include integer or decimal numbers.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement

4. ntext data type falls under which category?


a) Exact numerics
b) Character strings
c) Unicode character strings
d) None of the mentioned
View Answer

Answer: c
Explanation: ntext is fixed and variable-length data type for storing large non-
Unicode and Unicode character.
5. A column of type __________ may contain rows of different data types.
a) ntext
b) date
c) smallmoney
d) sql_variant
View Answer
Answer: d
Explanation: sql_variant is data type that stores values of various SQL Server-
supported data types.
Take SQL Server Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
6. You want to track date and time of the last write access per row?
a) Add TIMESTAMP column to the table
b) Add a DATETIME column to the table and assign getdate() as the default value
c) Add a DATETIME column to the table and write a trigger that sets its value
d) Add a UNIQUEIDENTIFIER column to the table and use it with SQL Server’s built-in
functions
View Answer

Answer: a
Explanation: The correct answer is Add a DATETIME column to the table and write a
trigger that sets its value.
7._________ is a spatial data type.
a) geometry
b) sql_variant
c) cursor
d) all of the mentioned
View Answer

Answer: b
Explanation: SQL Server supports the geometry and geography data types for storing
spatial data. These types support methods and properties that allow for the
creation, comparison, analysis, and retrieval of spatial data.
8. Which of the following data type is not present in SQL Server?
a) bit
b) boolean
c) hierarchyid
d) geography
View Answer

Answer: b
Explanation: SQL Server doesn’t have a Boolean data type, at least not by that
name. To store True/False, Yes/No, and On/Off values, use the bit data type. It
accepts only three values: 0, 1, and NULL.
9. ______________ is monetary data type in SQL Server.
a) Smallmoney
b) sql_variant
c) Cursor
d) None of the Mentioned
View Answer

Answer: a
Explanation: Monetary data types are data types that represent monetary or currency
values such as smallmoney and money.
10. Which of the data type has a storage size of 8 bytes?
a) timestamp
b) uniqueidentifier
c) real
d) smallmoney
View Answer

Answer: a
Explanation: uniqueidentifier, real and smallmoney data types have storage size of
16,4 and 4 bytes respectively.
1. Aggregate functions are functions that take a ___________ as input and return a
single value.
a) Collection of values
b) Single value
c) Aggregate value
d) Both Collection of values & Single value
View Answer

Answer: a
Explanation: None.
2.

SELECT __________
FROM instructor
WHERE dept name= ’Comp. Sci.’;
Which of the following should be used to find the mean of the salary ?
a) Mean(salary)
b) Avg(salary)
c) Sum(salary)
d) Count(salary)
View Answer

Answer: b
Explanation: Avg() is used to find the mean of the values.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement

3.

Take Database Management System Tests Now!


SELECT COUNT (____ ID)
FROM teaches
WHERE semester = ’Spring’ AND YEAR = 2010;
If we do want to eliminate duplicates, we use the keyword ______in the aggregate
expression.
a) Distinct
b) Count
c) Avg
d) Primary key
View Answer

Answer: a
Explanation: Distinct keyword is used to select only unique items from the
relation.
4. All aggregate functions except _____ ignore null values in their input
collection.
a) Count(attribute)
b) Count(*)
c) Avg
d) Sum
View Answer

Answer: b
Explanation: * is used to select all values including null.
5. A Boolean data type that can take values true, false, and________
a) 1
b) 0
c) Null
d) Unknown
View Answer

Answer: d
Explanation: Unknown values do not take null value but it is not known.
6. The ____ connective tests for set membership, where the set is a collection of
values produced by a select clause. The ____ connective tests for the absence of
set membership.
a) Or, in
b) Not in, in
c) In, not in
d) In, or
View Answer

Answer: c
Explanation: In checks, if the query has the value but not in checks if it does not
have the value.
7. Which of the following should be used to find all the courses taught in the Fall
2009 semester but not in the Spring 2010 semester .
a)

SELECT DISTINCT course id


FROM SECTION
WHERE semester = ’Fall’ AND YEAR= 2009 AND
course id NOT IN (SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010);
b)

SELECT DISTINCT course_id


FROM instructor
WHERE name NOT IN (’Fall’, ’Spring’);
c)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
d)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT course id, sec id, semester,
YEAR
FROM teaches
WHERE teaches.ID= 10101);
View Answer
Answer: a
Explanation: None.

8. The phrase “greater than at least one” is represented in SQL by _____


a) < all
b) < some
c) > all
d) > some
View Answer

Answer: d
Explanation: >some takes atlest one value above it .
9. Which of the following is used to find all courses taught in both the Fall 2009
semester and in the Spring 2010 semester .
a)

SELECT course id
FROM SECTION AS S
WHERE semester = ’Fall’ AND YEAR= 2009 AND
EXISTS (SELECT *
FROM SECTION AS T
WHERE semester = ’Spring’ AND YEAR= 2010 AND
S.course id= T.course id);
b)

SELECT name
FROM instructor
WHERE salary > SOME (SELECT salary
FROM instructor
WHERE dept name = ’Biology’);
c)

SELECT COUNT (DISTINCT ID)


FROM takes
WHERE (course id, sec id, semester, YEAR) IN (SELECT course id, sec id, semester,
YEAR
FROM teaches
WHERE teaches.ID= 10101);
d)

(SELECT course id
FROM SECTION
WHERE semester = ’Spring’ AND YEAR= 2010)
View Answer
Answer: a
Explanation: None.

10. We can test for the nonexistence of tuples in a subquery by using the _____
construct.
a) Not exist
b) Not exists
c) Exists
d) Exist
View Answer

Answer: b
Explanation: Exists is used to check for the existence of tuples.

1. Which of the following is a valid SQL type?


a) DATE
b) NUMERIC
c) FLOAT
d) All of the above
Answer: D

2.The full form of DDL is?


a) Dynamic Data Language
b) Detailed Data Language
c) Data Definition Language
d) Data Derivation Language
Answer: C

3. Which of the following is a legal expression in SQL?


a) SELECT NULL FROM EMPLOYEE;
b) SELECT NAME FROM EMPLOYEE;
c) SELECT NAME FROM EMPLOYEE WHERE SALARY = NULL;
d) None of the above
Answer: B

4. Which of the following is a comparison operator in SQL?


a) =
b) LIKE
c) BETWEEN
d) All of the above
Answer: D

5. Which of the following database object does not physically exist?


a) base table
b) index
c) view
d) none of the above
Answer: C
6. NULL is
a) the same as 0 for integer
b) the same as blank for character
c) the same as 0 for integer and blank for character
d) not a value
Answer: D

7. A file manipulation command that extracts some of the records from a file is
called
a) SELECT
b) PROJECT
c) JOIN
d) PRODUCT

Answer: A

8. Which one of the following is not true for a view:


a) View is derived from other tables.
b) View is a virtual table.
c) A view definition is permanently stored as part of the database.
d) View never contains derived columns.
Answer: C

9. To delete a particular column in a relation the command used is:


a) UPDATE
b) DROP
c) ALTER
d) DELETE
Answer: C

10. A data manipulation command the combines the records from one or more tables is
called
a) SELECT
b) PROJECT
c) JOIN
d) PRODUCT
Answer: C

11. View the Exhibit and examine the structure of the SALES, CUSTOMERS, PRODUCTS,
and TIMES
tables.
The PROD_ID column is the foreign key in the SALES table, which references the
PRODUCTS table.
Similarly, the CUST_ID and TIME_ID columns are also foreign keys in the SALES table
referencing the
CUSTOMERS and TIMES tables, respectively.
Evaluate the following CREATE TABLE command:
CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE)
AS
SELECT prod_id, cust_id, time_id
FROM sales;
Which statement is true regarding the above command?

A. The NEW_SALES table would not get created because the DEFAULT value cannot be
specified in the column definition.

B. The NEW_SALES table would get created and all the NOT NULL constraints defined
on the specified columns would be passed to the new table.

C. The NEW_SALES table would not get created because the column names in the CREATE
TABLE command and the SELECT clause do not match.

D. The NEW_SALES table would get created and all the FOREIGN KEY constraints
defined on the specified columns would be passed to the new table.

Answer: B

12. View the Exhibit to examine the description for the SALES table.
Which views can have all DML operations performed on it? (Choose all that apply.)

A.CREATE VIEW v3 AS SELECT * FROM SALES WHERE cust_id = 2034 WITH CHECK OPTION;

B. CREATE VIEW v1 AS SELECT * FROM SALES WHERE time_id<= SYSDATE - 2*365 WITH CHECK
OPTION;

C. CREATE VIEW v2 AS SELECT prod_id, cust_id, time_id FROM SALES WHERE time_id<=
SYSDATE - 2*365 WITH CHECK OPTION;

D. CREATE VIEW v4 AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES WHERE


time_id<= SYSDATE - 2*365 GROUP BY prod_id, cust_id WITH CHECK OPTION;

Answer: AB

13. You need to extract details of those products in the SALES table where the
PROD_ID column containsthe string '_D123'.Which WHERE clause could be used in the
SELECT statement to get the required output?
A.WHERE prod_id LIKE '%_D123%' ESCAPE '_'
B.WHERE prod_id LIKE '%\_D123%' ESCAPE '\'
C. WHERE prod_id LIKE '%_D123%' ESCAPE '%_'
D. WHERE prod_id LIKE '%\_D123%' ESCAPE '\_'

Answer: B
14. Which two statements are true regarding single row functions? (Choose two.)
A. They accept only a single argument.
B. They can be nested only to two levels.
C. Arguments can only be column values or constants.
D. They always return a single result row for every row of a queried table.
E. They c an return a data type value different from the one that is referenced.

Answer: DE

15. Which SQL statements would display the value 1890.55 as $1,890.55? (Choose
three .)
A. SELECT TO_CHAR(1890.55,'$0G000D00')
FROM DUAL;
B.SELECT TO_CHAR(1890.55,'$9,999V99')
FROM DUAL;

C.SELECT TO_CHAR(1890.55,'$99,999D99')
FROM DUAL;

D.SELECT TO_CHAR(1890.55,'$99G999D00')
FROM DUAL;

E.SELECT TO_CHAR(1890.55,'$99G999D99')
FROM DUAL;

Answer: ADE

16. Examine the structure of the SHIPMENTS table:

name Null Type

PO_ID NOT NULL NUMBER(3)

PO_DATE NOT NULL DATE

SHIPMENT_DATE NOT NULL DATE

SHIPMENT_MODE VARCHAR2(30)

SHIPMENT_COST NUMBER(8,2)

You want to generate a report that displays the PO_ID and the penalty amount to be
paid if the

SHIPMENT_DATE is later than one month from the PO_DATE. The penalty is $20 per day.

Evaluate the following two queries:

SQL> SELECT po_id, CASE

WHEN MONTHS_BETWEEN (shipment_date,po_date)>1 THEN

TO_CHAR((shipment_date - po_date) * 20) ELSE 'No Penalty' END PENALTY

FROM shipments;

SQL>SELECT po_id, DECODE


(MONTHS_BETWEEN (po_date,shipment_date)>1,

TO_CHAR((shipment_date - po_date) * 20), 'No Penalty') PENALTY

FROM shipments;

Which statement is true regarding the above commands?

A.Both execute successfully and give correct results.

B. Only the first query executes successfully but gives a wrong result.

C. Only the first query executes successfully and gives the correct result.

D. Only the second query executes successfully but gives a wrong result.

E. Only the second query executes successfully and gives the correct result.

Answer: C

17. Which two statements are true regarding the USING and ON clauses in table
joins? (Choose two.)

A. Both USING and ON clauses can be used for equijoins and nonequijoins.
B.A maximum of one pair of columns can be joined between two tables using the ON
clause.
C.The ON clause can be used to join tables on columns that have different names but
compatible data types.
D.The WHERE clause can be used to apply additional conditions in SELECT statements
containing the ON or the USING clause.

Answer: CD

18. View the Exhibit and examine the structure of the CUSTOMERS table.

Which two tasks would require subqueries or joins to be executed in a single


statement? (Choose two.)

A. listing of customers who do not have a credit limit and were born before 1980

B. finding the number of customers, in each city, whose marital status is 'married'

C. finding the average credit limit of male customers residing in 'Tokyo' or


'Sydney'

D. listing of those customers whose credit limit is the same as the credit limit of
customers residing in the city 'Tokyo'

E. finding the number of customers, in each city, whose credit limit is more than
the average credit limit of all the customers

Answer: DE

19. Which statement is true regarding the INTERSECT operator?

A. It ignores NULL values.


B. Reversing the order of the intersected tables alters the result.
C. The names of columns in all SELECT statements must be identical.

D. The number of columns and data types must be identical for all SELECT statements
in the query.

Answer: D

20.View the Exhibit; examine the structure of the PROMOTIONS table.

Each promotion has a duration of at least seven days .


Your manager has asked you to generate a report, which provides the weekly cost for
each promotion
done
Which query would achieve the required result?

A.SELECT promo_name, promo_cost/promo_end_date-promo_begin_date/7 FROM promotions;


B.SELECT promo_name,(promo_cost/promo_end_date-promo_begin_date)/7 FROM promotions
C.SELECT promo_name, promo_cost/(promo_end_date-promo_begin_date/7) FROM
promotions;
D.SELECT promo_name, promo_cost/((promo_end_date-promo_begin_date)/7) FROM
promotions;

Answer: D

21. View the Exhibit and examine the structure of the PRODUCTS table.

All products have a list price.

You issue the following command to display the total price of each product after a
discount of 25% and a tax

of 15% are applied on it. Freight charges of $100 have to be applied to all the
products.

SQL>SELECT prod_name, prod_list_price-(prod_list_price*(25/100))

+(prod_list_price -(prod_list_price*(25/100))*(15/100))+100

AS "TOTAL PRICE"
FROM products;

What would be the outcome if all the parenthese s are removed from the above
statement?
A.It produces a syntax error.
B.The result remains unchanged.
C.The total price value would be lower than the correct value.
D.The total price value would be higher than the correct value.

Answer: B

22. The following are components of a database except ________ .


A.user data
B.metadata
C.reports
D.indexes

Answer: C

24. An application where only one user accesses the database at a given time is an
example of a(n) ________ .
A.single-user database application
B.multiuser database application
C.e-commerce database application
D.data mining database application

Answer: A

25. An on-line commercial site such as Amazon.com is an example of a(n) ________ .


A.single-user database application
B.multiuser database application
C.e-commerce database application
D.data mining database application

Answer: C

26. The following are functions of a DBMS except ________ .


A.creating and processing forms
B.creating databases
C.processing data
D.administrating databases

Answer: A

27. Helping people keep track of things is the purpose of a(n) ________ .
A.database
B.table
C.instance
D.relationship

Answer: A

28. You have run an SQL statement that asked the DBMS to display data in a table
named USER_TABLES. The results include columns of data labeled "TableName,"
"NumberOfColumns" and "PrimaryKey." You are looking at ________ .
A.user data.
B.metadata
C.A report
D.indexes

Answer: B

29. Every time attribute A appears, it is matched with the same value of attribute
B, but not the same value of attribute C. Therefore, it is true that:
A.A ? B.
B.A ? C.
C.A ? (B,C).
D.(B,C) ? A.

Answer: A
30. The different classes of relations created by the technique for preventing
modification anomalies are called:
A.normal forms.
B.referential integrity constraints.
C.functional dependencies.
D.None of the above is correct.

Answer: A
31. The primary key is selected from the:
A.composite keys.
B.determinants.
C.candidate keys.
D.foreign keys.

Answer: C
32. A functional dependency is a relationship between or among:
A.tables.
B.rows.
C.relations.
D.attributes.

Answer: D
33. View the Exhibit and examine the structure of the SALES, CUSTOMERS, PRODUCTS,
and TIMES tables.
The PROD_ID column is the foreign key in the SALES table, which references the
PRODUCTS table.
Similarly, the CUST_ID and TIME_ID columns are also foreign keys in the SALES table
referencing the
CUSTOMERS and TIMES tables, respectively.
Evaluate the following CREATE TABLE command:
CREATE TABLE new_sales(prod_id, cust_id, order_date DEFAULT SYSDATE)
AS
SELECT prod_id, cust_id, time_id
FROM sales;
Which statement is true regarding the above command?

A. The NEW_SALES table would not get created because the DEFAULT value cannot be
specified in the column definition.
B. The NEW_SALES table would get created and all the NOT NULL constraints defined
on the specified columns would be passed to the new table.
C. The NEW_SALES table would not get created because the column names in the CREATE
TABLE command and the SELECT clause do not match.
D. The NEW_SALES table would get created and all the FOREIGN KEY constraints
defined on the specified columns would be passed to the new table.
Answer: B

34. View the Exhibit to examine the description for the SALES table.
Which views can have all DML operations performed on it? (Choose all that apply.)
A.CREATE VIEW v3 AS SELECT * FROM SALES WHERE cust_id = 2034 WITH CHECK OPTION;
B. CREATE VIEW v1 AS SELECT * FROM SALES WHERE time_id<= SYSDATE - 2*365 WITH CHECK
OPTION;
C. CREATE VIEW v2 AS SELECT prod_id, cust_id, time_id FROM SALES WHERE time_id<=
SYSDATE - 2*365 WITH CHECK OPTION;
D. CREATE VIEW v4 AS SELECT prod_id, cust_id, SUM(quantity_sold) FROM SALES WHERE
time_id<= SYSDATE - 2*365 GROUP BY prod_id, cust_id WITH CHECK OPTION;

Answer: AB

35.You need to extract details of those products in the SALES table where the
PROD_ID column containsthe string '_D123'.Which WHERE clause could be used in the
SELECT statement to get the required output?
A.WHERE prod_id LIKE '%_D123%' ESCAPE '_'
B.WHERE prod_id LIKE '%\_D123%' ESCAPE '\'
C. WHERE prod_id LIKE '%_D123%' ESCAPE '%_'
D. WHERE prod_id LIKE '%\_D123%' ESCAPE '\_'
Answer: B

36. Which two statements are true regarding single row functions? (Choose two.)
A. They accept only a single argument.
B. They can be nested only to two levels.
C. Arguments can only be column values or constants.
D. They always return a single result row for every row of a queried table.
E. They c an return a data type value different from the one that is referenced.

Answer: DE

37. Which SQL statements would display the value 1890.55 as $1,890.55? (Choose
three .)
A. SELECT TO_CHAR(1890.55,'$0G000D00')
FROM DUAL;
B.SELECT TO_CHAR(1890.55,'$9,999V99')
FROM DUAL;
C.SELECT TO_CHAR(1890.55,'$99,999D99')
FROM DUAL;
D.SELECT TO_CHAR(1890.55,'$99G999D00')
FROM DUAL;
E.SELECT TO_CHAR(1890.55,'$99G999D99')
FROM DUAL;
Answer: ADE

38.Examine the structure of the SHIPMENTS table:


name Null Type
PO_ID NOT NULL NUMBER(3)
PO_DATE NOT NULL DATE
SHIPMENT_DATE NOT NULL DATE
SHIPMENT_MODE VARCHAR2(30)
SHIPMENT_COST NUMBER(8,2)
You want to generate a report that displays the PO_ID and the penalty amount to be
paid if the
SHIPMENT_DATE is later than one month from the PO_DATE. The penalty is $20 per day.
Evaluate the following two queries:
SQL> SELECT po_id, CASE

WHEN MONTHS_BETWEEN (shipment_date,po_date)>1 THEN


TO_CHAR((shipment_date - po_date) * 20) ELSE 'No Penalty' END PENALTY
FROM shipments;
SQL>SELECT po_id, DECODE
(MONTHS_BETWEEN (po_date,shipment_date)>1,
TO_CHAR((shipment_date - po_date) * 20), 'No Penalty') PENALTY
FROM shipments;
Which statement is true regarding the above commands?
A.Both execute successfully and give correct results.
B.Only the first query executes successfully but gives a wrong result.
C.Only the first query executes successfully and gives the correct result.
D.Only the second query executes successfully but gives a wrong result.
E.Only the second query executes successfully and gives the correct result.
Answer: C
39. Which two statements are true regarding the USING and ON clauses in table
joins? (Choose two.)
A.Both USING and ON clauses can be used for equijoins and nonequijoins.
B.A maximum of one pair of columns can be joined between two tables using the ON
clause.
C.The ON clause can be used to join tables on columns that have different names but
compatible data types.
D.The WHERE clause can be used to apply additional conditions in SELECT statements
containing the ON or the USING clause.
Answer: CD

40. View the Exhibit and examine the structure of the CUSTOMERS table.
Which two tasks would require subqueries or joins to be executed in a single
statement? (Choose two.)

A. listing of customers who do not have a credit limit and were born before 1980
B. finding the number of customers, in each city, whose marital status is 'married'
C. finding the average credit limit of male customers residing in 'Tokyo' or
'Sydney'
D. listing of those customers whose credit limit is the same as the credit limit of
customers residing in the city 'Tokyo'
E. finding the number of customers, in each city, whose credit limit is more than
the average credit limit of all the customers
Answer: DE

41. Which statement is true regarding the INTERSECT operator?


A. It ignores NULL values.
B. Reversing the order of the intersected tables alters the result.
C. The names of columns in all SELECT statements must be identical.
D. The number of columns and data types must be identical for all SELECT statements
in the query.
Answer: D

42.View the Exhibit; examine the structure of the PROMOTIONS table.


Each promotion has a duration of at least seven days .
Your manager has asked you to generate a report, which provides the weekly cost for
each promotion done Which query would achieve the required result?

A.SELECT promo_name, promo_cost/promo_end_date-promo_begin_date/7 FROM promotions;


B.SELECT promo_name,(promo_cost/promo_end_date-promo_begin_date)/7 FROM promotions
C.SELECT promo_name, promo_cost/(promo_end_date-promo_begin_date/7) FROM
promotions;
D.SELECT promo_name, promo_cost/((promo_end_date-promo_begin_date)/7) FROM
promotions;

Answer: D

43. View the Exhibit and examine the structure of the PRODUCTS table.
All products have a list price.
You issue the following command to display the total price of each product after a
discount of 25% and a tax of 15% are applied on it. Freight charges of $100 have to
be applied to all the products.
SQL>SELECT prod_name, prod_list_price-(prod_list_price*(25/100))
+(prod_list_price -(prod_list_price*(25/100))*(15/100))+100
AS "TOTAL PRICE"
FROM products;

44. You can add a row using SQL in a database with which of the following?
A.ADD
B.CREATE
C.INSERT
D.MAKE
Answer: C
45. The command to remove rows from a table 'CUSTOMER' is:
A.REMOVE FROM CUSTOMER ...
B.DROP FROM CUSTOMER ...
C.DELETE FROM CUSTOMER WHERE ...
D.UPDATE FROM CUSTOMER ...
Answer: C

46. The SQL WHERE clause:


A. limits the column data that are returned.
B. limits the row data are returned.
C. Both A and B are correct.
D. Neither A nor B are correct.

Answer: b

47. Which of the following is the original purpose of SQL?


A. To specify the syntax and semantics of SQL data definition language
B. To specify the syntax and semantics of SQL manipulation language
C. To define the data structures
D. All of the above.
Answer: D

48. The wildcard in a WHERE clause is useful when?


A. An exact match is necessary in a SELECT statement.
B. An exact match is not possible in a SELECT statement.
C. An exact match is necessary in a CREATE statement.
D. An exact match is not possible in a CREATE statement.

Answer: A

49. A view is which of the following?


A. A virtual table that can be accessed via SQL commands
B. A virtual table that cannot be accessed via SQL commands
C. A base table that can be accessed via SQL commands
D. A base table that cannot be accessed via SQL commands
Answer: A

50. The command to eliminate a table from a database is:


A.REMOVE TABLE CUSTOMER;
B.DROP TABLE CUSTOMER;
C.DELETE TABLE CUSTOMER;
D.UPDATE TABLE CUSTOMER;

Answer: B

51. ON UPDATE CASCADE ensures which of the following?


A. Normalization
B. Data Integrity
C. Materialized Views
D. All of the above.

Answer: B
52. SQL data definition commands make up a(n) ________ .
A.DDL
B.DML
C.HTML
D.XML
Answer: A

53. Which of the following is valid SQL for an Index?


A.CREATE INDEX ID;
B.CHANGE INDEX ID;
C.ADD INDEX ID;
D.REMOVE INDEX ID;

Answer: C

54. The SQL keyword(s) ________ is used with wildcards.


A.LIKE only
B.IN only
C.NOT IN only
D.IN and NOT IN
Answer: A

55. Which of the following is the correct order of keywords for SQL SELECT
statements?
A.SELECT, FROM, WHERE
B.FROM, WHERE, SELECT
C.WHERE, FROM,SELECT
D.SELECT,WHERE,FROM
Answer: A

56. A subquery in an SQL SELECT statement is enclosed in:


A.braces -- {...}.
B.CAPITAL LETTERS.
C.parenthesis -- (...) .
D.brackets -- [...].
Answer: C

57. The result of a SQL SELECT statement is a(n) ________ .


A.report
B.form
C.file
D.table
Answer: A

58. Which of the following are the five built-in functions provided by SQL?
A.COUNT, SUM, AVG, MAX, MIN
B.SUM, AVG, MIN, MAX, MULT
C.SUM, AVG, MULT, DIV, MIN
D.SUM, AVG, MIN, MAX, NAME
Answer: A

59. In an SQL SELECT statement querying a single table, according to the SQL-92
standard the asterisk (*) means that:
A. all columns of the table are to be returned.
B. all records meeting the full criteria are to be returned.
C. all records with even partial criteria met are to be returned.
D. None of the above is correct.
Answer: A
60. The HAVING clause does which of the following?
A. Acts like a WHERE clause but is used for groups rather than rows.
B. Acts like a WHERE clause but is used for rows rather than columns.
C. Acts like a WHERE clause but is used for columns rather than groups.
D. Acts EXACTLY like a WHERE clause.
Answer: A

61. The SQL -92 wildcards are ____ and ____ .


A. asterisk (*); percent sign (%)
B. percent sign (%); underscore (_)
C. underscore(_); question mark (?)
D. question mark (?); asterisk (*)
Answer: B

62.To remove duplicate rows from the results of an SQL SELECT statement, the
________ qualifier specified must be included.
A.ONLY
B.UNIQUE
C.DISTINCT
D.SINGLE
Answer: C

63. The benefits of a standard relational language include which of the following?
A. Reduced training costs
B. Increased dependence on a single vendor
C. Applications are not needed.
D. All of the above.
Answer: c

64. DROP TABLE table_name command inserts data into a table


a) TRUE
b) FALSE
Answer: B

64. What is the primary clause in a SELECT statement?


A. SELECT
B. FROM
C. WHERE
D. GROUP BY
E. HAVING
Answer: A

65. Which clause specifies the tables or views from which to retrieve the data?
A. SELECT
B. FROM
C. WHERE
D. GROUP BY
E. HAVING
Answer: B

66. Which clause is used to filter nonaggregate data?


A. SELECT
B. FROM
C. WHERE
D. GROUP BY
E. HAVING
Answer: C

67. When an aggregate function is used, which clause divides the data into distinct
groups?
A. SELECT
B. FROM
C. WHERE
D. GROUP BY
E. HAVING
Answer: D

68. What symbol is used to select all columns from a table?


A. /
B. \
C. *
D. &
Answer: C

69. What keyword is used to eliminate any duplicate rows?


A. DISTINCT
B. WHERE
C. HAVING
D. FROM
Answer: A

70. What clause sorts the rows returned?


A. GROUP BY
B. FROM
C. WHERE
D. ORDER BY
Answer: D

71. Which function is used to convert a value to a specific data type?


A. SUM B.
B. CAST
C. C. MOD
D. D. FLOOR
Answer: B

72. Combining two character items is known as ________.


A. Combining
B. Character modification
C. Concatenation
D. Casting
Answer: C

73. What keyword is used to provide a name for an expression in a SELECT clause?
A. DISTINCT
B. AS
C. HAVING
D. IS
Answer: B

74. What is a missing or unknown value?


A. ZERO
B. EMPTY
C. NOTHING
D. NULL
Answer: D

75. What data type is used to store the quantity of time between two dates or
times?
A. DATETIME
B. INTERVAL
C. EXACT NUMERIC
D. APPROXIMATE NUMERIC
Answer: B

76. Which predicate tests whether the value of a given value expression matches an
item in a given list of values?
A. Comparison
B. BETWEEN
C. IN
D. LIKE
E. IS NULL
Answer: C

77. Which predicate enables you to test whether a character string value expression
matches a specified character string pattern?
A. Comparison
B. BETWEEN
C. IN
D. LIKE
E. IS NULL
Answer: D

78. Which predicate uses one of six operators to compare one value expression to
another value expression?
A. Comparison B. BETWEEN C. IN
D. LIKE E. IS NULL
Answer: A

79. Which predicate lets you test whether the value of a given value expression
falls within a specified range of values?
A. Comparison
B. BETWEEN
C. IN
D. LIKE
E. IS NULL
Answer: B

80. Which operator is used to include rows in the result set that did not meet the
condition of the predicate?
A. IS
B. ANY
C. NOT
D. ALL
Answer: C

81. Which operator do you use when all the conditions you combine must be met in
order for a row to be included in a result set?
A. OR
B. AND
C. NOT
D. ANY
E. ALL
Answer: B

82. Which operator do you use when either of the conditions you combine can be met
in order for a row to be included in a result set?
A. OR
B. AND
C. NOT
D. ANY
E. ALL
Answer: A

83. IDENTIFY THE THREE (3) MAIN RELATIONSHIP TYPES THAT EXIST BETWEEN ANY TWO
TABLES? CHOOSE (3)
A. ONE TO ONE
B. ONE TO MANY
C. MANY TO MANY
D. ONE TO OTHER
E. MANY TO OTHERS
ANSWER: ABC
84. IN THIS RELATIONHIP, FOR EACH ROW IN ONE TABLE, THERE EXISTS AT MOST ONE
RELATED ROW IN THE OTHER TABLE..
A. MANY TO OTHERS
B. ONE TO OTHER
C. MANY TO MANY
D. ONE TO MANY
E. ONE TO ONE
ANSWER: E
85. A SET OF RULES THAT HELP IMPROVE DATABASE DESIGN AND ALSO ENSURE AN OPTIMUM AND
EFFICIENT STRUCTURE FOR ANY DATABASE IS KNOWN AS….
A. ENTITY CLUSTER
B. REDUNDANCY
C. ENTITY SUPERTYPE
D. NORMALIZATION
E. CONSTRAINT
ANSWER: D
86. WHAT ARE THE TWO FORMS OF AUTHENTICATION IN SQL SERVER?
A. WINDOWS AUTHENTICATION AND SOFTWARE AUTHENTICATION
B. WINDOWS AUTHENTICATION AND MIXED MODE AUTHENTICATION
C. SQL AUTHENTICATION AND WINDOWS AUTHENTICATION
D. APPLICATION AUTHENTICATION AND SOFTWARE AUTHENTICATION
E. SQL AUTHENTICATION AND APPLICATION AUTHENTICATION
ANSWER: B
87. IDENTIFY THREE FILES SQL SERVER USES TO STORE ITS DATA
A. PRIMARY FILE, CONTROL FILE, REDO FILE
B. PRIMARY FILE, SECONDARY FILE, LOG FILE
C. SYSTEM FILE, APPLICATION FILE, LOG FILE
D. TRANSACTION LOG FILE, PRIMARY FILE, SYSTEM FILE
E. SECONDARY FILE, SYSTEM FILE, APPLICATION FILE
ANSWER: B
88. WHICH OF THESE STATEMENTS IS RESPONSIBLE FOR SEPARATING SECTIONS OF CODE?
A. INSERT
B. UPDATE
C. CREATE
D. DELETE
E. GO
F. ALTER
ANSWER: E
89. IN SQL SERVER 2008, WHICH MODIFIER IS USED TO AUTO – GENERATE UNIQUE NUMBERS
FOR A COLUMN?
A. SEQUENCE
B. AUTONUMBER
C. SYNONYM
D. INDEX
E. IDENTITY
ANSWER: E
90.WHICH OF THESE DETERMINE THE WAY A COLUMN BEHAVES?
A. INDEX
B. CONSTRAINT
C. NORMALIZATION
D. CLUSTER
E. CASCADE
ANSWER: B
91. IN AN SQL SERVER DATAFILE, WHAT IS THE SMALLEST UNIT OF STORAGE?
A. AN EXTENT
B. A PAGE
C. A WORKSHEET
D. A PRIMARY FILE
E. A LOG FILE
ANSWER: B
92.A PLACE IN THE MEMORY THAT IS DECLARED BEFOREHAND AND GIVEN A NAME IS KNOWN AS:
A. AN ENTITY
B. AN ATTRIBUTE
C. A VARIABLE
D. A RECORD
E. AN INSTANCE
ANSWER: C

93. You need to ensure that tables are not dropped from your database. What should
you do?
A. Create a DDL trigger that contains COMMIT.
B. Create a DML trigger that contains COMMIT.
C. Create a DDL trigger that contains ROLLBACK.
D. Create a DML trigger that contains ROLLBACK.

Answer: C

94. You have the following two tables.


The foreign key relationship between these tables has CASCADE DELETE enabled.
You need to remove all records from the Orders table.
Which Transact-SQL statement should you use?
A. DROP TABLE Orders
B. DELETE FROM Orders
C. TRUNCATE TABLE Orders
D. DELETE FROM OrderDetails

Answer: B

95. What would DISTINCT in a select statement do data retrieval?


A. All duplicates in the table would be retrieved from the table.
B. Rows would be retrieved but all duplicates are eliminated from the result of the
select statement.
C. Both duplicates and unique rows would be retireved from the table
D. DISTINCT would not have any effect on the table

Answer: B

96. Study the T-SQL code below and answer the question that follows :
SELECT DrugID, DrugName, Quantity
FROM DrugDetails.DrugInStock
WHERE DrugName LIKE '%pharma%';
What is the % in the select statement?
A. An operator
B. An operand
C. A predicate
D. A wildcard

Answer: D

97. Study the T-SQL code below and answer the question that follows :
SELECT DrugID, DrugName, Quantity
FROM DrugDetails.DrugInStock
WHERE DrugName LIKE '%pharma%';
The WHERE clause of the select statement restricts rows to the condition presented
within.
A. True
B. False

Answer: A

98. For transactions to finally take place in a database.


A. Commit
B. Rollback
C. Save

Answer: A

99. Restrictions to defined on tables to check the validity of data


A. Constraint
B. Triggers
C. Procedures
D. Roles

Answer: A

100. A column named ACCOUNTID has identity of seed value being 5 and an increment
value being 1000.
What would be the ID of the 1st row in the column?
A. 5
B. 10
C. 1000
D. 1005

Answer: A

101. A column named ACCOUNTID has identity of seed value being 5 and an increment
value being 1000.
What would be the ID of the 10th row in the column?
A. 8005
B. 5005
C. 9005
D. 10005

Answer: C

102. What would happen when the Transact-SQL code below is executed on a SQL Server
instance?
DELETE from dbo.accounts
A. The first row of the table would be deleted
B. The table would be deleted from its database
C. The last row of the table would be deleted
D. All rows of the table would be deleted
Answer: D

103. Study the Transact-SQL code below and answer the question that follows
SELECT city + ' ' + street + ' ' + state + ' ' + country
FROM dbo.accountdetails
WHERE accountholder LIKE "%tina";
What is the function of the + in the select statement?

A. Addition
B. Concatenation
C. Combinding
D. Compressing

Answer: B

104. Study the Transact-SQL code below and answer the question that follows
SELECT city + ' ' + street + ' ' + state + ' ' + country Address
FROM dbo.accountdetails
WHERE accountholder LIKE "%tina";
How many columns would be retrieved after executing the code?
A. 2
B. 4
C. 1
D. 5

Answer: C

105. Study the Transact-SQL code below and answer the question that follows
SELECT city + ' ' + street + ' ' + state + ' ' + country AS Address
FROM dbo.accountdetails
WHERE accountholder LIKE "%tina";
The name of the column that would be produced after executing the code is called a
column alias.
A. True
B. False

Answer: A

106. A table having its name beginning with a single # symbol.


A. A permanent table
B. A system table
C. A temporary table
D. None of the above

Answer: C

107. Reserved words can be used as database object names.


A. True
B. False

Answer: B

108. A column having identity defined on it could contain duplicates.


A. True
B. False

Answer: B

109. DDL triggers are executed when


A. There has been a change in table structure
B. There has been a change in data
C. There has been a change in query
D. There has been the execution of a DDL command

Answer: D

110. Functions can be used in the following except?


A.SELECT list
B.An expression
C.WHERE clause
D.All the above
e. All but B

Answer: E

111. You can add a row using SQL in a database with which of the following?
A.ADD
B.INSERT
C.CREATE
D.MAKE

Answer: B

112. The command to remove rows from a table 'CUSTOMER' is:


A.REMOVE FROM CUSTOMER ...
B.DROP FROM CUSTOMER ...
C.DELETE FROM CUSTOMER WHERE ...
D.UPDATE FROM CUSTOMER ...

Answer: C

113.Which of the following is not an SQL keyword or SQL clause?


A.INVERT
B.INSERT
C.UPDATE
D.SELECT
Answer: A

114.Which of the following SQL clauses is used to select data from 2 or more
tables?
A.WHERE
B.HAVING
C.JOIN
D.None of the above
Answer: C

115.he NULL SQL keyword is used to …


A.Represent 0 values.
B.Represent a missing or unknown value. NULL in SQL represents nothing.
C.Represent positive infinity.
D.Represent negative infinity.
Answer: B

116.A database can be said to be a container for objects that not only store data,
but also enables data storage and retrieval to operate in a secure and safe manner.
A.True
B.False
C.None of the above
Answer: A

117.Arranging data so that retrieval is as efficient as possible and at the same


time reducing any duplication is known as
A.Gathering
B.Normalizing
C.Sorting
D.None of the above
Answer: C

118.Query Editor sends queries to a database using T-SQL.


A.True
B.False
C.None of the above
Answer: A

119.What is ANSI?
A.American National Studios Institute
B.American National Standards Institute
C.American National Servers Institute
D.None of the above
Answer: B

120.What is SSMS?
A.SQL Server Managerial Studio
B.SQL Server Management Standard
C.SQL Server Management Studio
D.None of the above
Answer: C

121.When SQL Server is installed more than once on a computer, each installation is
called an instance.
A.True
B.False
C.None of the above
Answer: A

122.The following are all Data Definition Language (DDL) except.


A.ALTER
B.INSERT
C.CREATE
D.DROP
Answer: B

123.Which system database contains the metadata about your database, logins, and
configuration information about the instance?
A.Tempdb
B.Master
C.Model
D.Msdb
Answer: B

124.Which of these databases is a temporary database whose lifetime is the duration


of a SQL Server session?
A.Master
B.Tempdb
C.AdventurerWorks
D.Model
Answer: B

125.Which of this is not a data type in SQL Server 2005.


A.Nchar
B.Nvarchar
C.Smalldate
D.String
Answer: D

126.The Structured query language (SQL) used in SQL Server is:


A.Transact SQL (T-SQL)
B.PL SQL
C.MY SQL
D.MS Access SQL
Answer: A
127.The __________ system database is used as a template for creating all new
databases
A. Master
B. TempDB
C. Model
D. MSDB
E. Pub
Answer: C

128. …………………… is the full form of SQL.


A) Standard Query Language
B) Sequential Query Language
C) Structured Query Language
D) Server Side Query Language
Answer: C

129. SQL Server 2005 NOT includes the following system database ………….
A) tempdb Database
B) Master Database
C) Model Database
D) sqldb Database
Answer: D

130. SQL Server stores index information in the ………………… system table.
A) sysindexes
B) systemindexes
C) sysind
D) sysindexes
Answer: D

131. ………………… is a read-only database that contains system objects that are included
with SQL Server 2005.
A) Resource Database
B) Master Database
C) Model Database
D) msdb Database
Answer: A

132. The SQL Server services includes …………………


A) SQL server agent
B) Microsoft distribution transaction coordinator
C) Both a & b
D) None of the above
Answer: C

133. …………………. is a utility to capture a continuous record of server activity and


provide auditing capability.
A) SQL server profile
B) SQL server service manager
C) SQL server setup
D) SQL server wizard
Answer: B

134. The query used to remove all references for the pubs and newspubs databases
from the system tables is ……………………..
A) DROP DATABASE pubs, newpubs;
B) DELETE DATABASE pubs, newpubs;
C) REMOVE DATABASE pubs, newpubs;
D) DROP DATABASE pubs and newpubs;
Answer: A

135. …………………. clause specifies the groups into which output rows are to be placed
and, if aggregate functions are included in the SELECT clause.
A) ORDER BY
B) GROUP
C) GROUP BY
D) GROUP IN
Answer: C
136. ……………… are predefined and maintained SQL Server where users cannot assign or
directly change the values.
A) Local Variables
B) Global Variables
C) Assigned Variables
D) Direct Variables
Answer: B

137. Microsoft SQL Server NOT uses which of the following operator category?
A) Bitwise Operator
B) Unary Operator
C) Logical Operator
D) Real Operator
Answer: D

138. Which of the following query is correct for using comparison operators in SQL?
A) SELECT sname, coursename FROM studentinfo WHERE age>50 and <80;
B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;
C) SELECT sname, coursename FROM studentinfo WHERE age>50 and WHERE age<80;
D) None of the above
Answer: B

139.How to select all data from studentinfo table starting the name from letter
‘r’?
A) SELECT * FROM studentinfo WHERE sname LIKE ‘r%';
B) SELECT * FROM studentinfo WHERE sname LIKE ‘%r%';
C) SELECT * FROM studentinfo WHERE sname LIKE ‘%r';
D) SELECT * FROM studentinfo WHERE sname LIKE ‘_r%';
Answer: A
140. Which of the following SQL query is correct for selecting the name of staffs
from ‘tblstaff’ table where salary is 15,000 or 25,000?
A) SELECT sname from tblstaff WHERE salary IN (15000, 25000);
B) SELECT sname from tblstaff WHERE salary BETWEEN 15000 AND 25000;
C) Both A and B
D) None of the above
Answer: A

141. The SELECT statement, that retrieves all the columns from empinfo table name
starting with d to p is ……………………..
A) SELECT ALL FROM empinfo WHERE ename like ‘[d-p]%';
B) SELECT * FROM empinfo WHERE ename is ‘[d-p]%';
C) SELECT * FROM empinfo WHERE ename like ‘[p-d]%';
D) SELECT * FROM empinfo WHERE ename like ‘[d-p]%';
Answer: D

142. Select a query that retrieves all of the unique countries from the student
table?
A) SELECT DISTINCT coursename FROM studentinfo;
B) SELECT UNIQUE coursename FROM studentinfo;
C) SELECT DISTINCT coursename FROM TABLE studentinfo;
D) SELECT INDIVIDUAL coursename FROM studentinfo;
Answer: A

143. Which query is used for sorting data that retrieves the all the fields from
empinfo table and listed them in the ascending order?
A) SELECT * FROM empinfo ORDER BY age;
B) SELECT * FROM empinfo ORDER age;
C) SELECT * FROM empinfo ORDER BY COLUMN age;
D) SELECT * FROM empinfo SORT BY age;
Answer: A

144. Select the right statement to insert values to the stdinfo table.
A) INSERT VALUES (“15″, “Hari Thapa”, 45, 5000) INTO stdinfo;
B) INSERT VALUES INTO stdinfo (“15″, “Hari Thapa”, 45, 5000);
C) INSERT stdinfo VALUES (“15″, “Hari Thapa”, 45, 5000);
D) INSERT INTO stdinfo VALUES (“15″, “Hari Thapa”, 45, 5000);
Answer: D

145. How to Delete records from studentinfo table with name of student ‘Hari
Prasad’?
A) DELETE FROM TABLE studentinfo WHERE sname=’Hari Prasad';
B) DELETE FROM studentinfo WHERE sname=’Hari Prasad';
C) DELETE FROM studentinfo WHERE COLUMN sname=’Hari Prasad';
D) DELETE FROM studentinfo WHERE sname LIKE ‘Hari Prasad';
Answer: B

146. Constraint checking can be disabled in existing …………. and ………….. constraints
so that any data you modify or add to the table is not checked against the
constraint.
A) CHECK, FOREIGN KEY
B) DELETE, FOREIGN KEY
C) CHECK, PRIMARY KEY
D) PRIMARY KEY, FOREIGN KEY
Answer: A

147. ………………… joins two or more tables based on a specified column value not
equaling a specified column value in another table.

A) OUTER JOIN
B) NATURAL JOIN
C) NON-EQUIJOIN
D) EQUIJOIN
Answer: C
148. …………………… is a procedural extension of Oracle – SQL that offers language
constructs similar to those in imperative programming languages.
A) SQL
B) PL/SQL
C) Advanced SQL
D) PQL
Answer: B

149. ……………….. combines the data manipulating power of SQL with the data processing
power of Procedural languages.
A) PL/SQL
B) SQL
C) Advanced SQL
D) PQL
Answer: A

150. ………………. has made PL/SQL code run faster without requiring any additional work
on the part of the programmer.
A) SQL Server
B) My SQL
C) Oracle
D) SQL Lite
Answer: C

151. A line of PL/SQL text contains groups of characters known as …………………..


A) Lexical Units
B) Literals
C) Textual Units
D) Identifiers
Answer: A
152. We use …………………… name PL/SQL program objects and units.
A) Lexical Units
B) Literals
C) Delimiters
D) Identifiers
Answer: D
153. A ……………….. is an explicit numeric, character, string or Boolean value not
represented by an identifier.
A) Comments
B) Literals
C) Delimiters
D) Identifiers
Answer: B
154. If no header is specified, the block is said to be an …………………. PL/SQL block.
A) Strong
B) Weak
C) Empty
D) Anonymous
Answer: D
155. …………. is a sequence of zero or more characters enclosed by single quotes.
A) Integers literal
B) String literal
C) String units
D) String label
Answer: B
156. In ……………………, the management of the password for the account can be handled
outside of oracle such as operating system.
A) Database Authentication
B) Operating System Authentication
C) Internal Authentication
D) External Authentication
Answer: B
157. In ………………………. of Oracle, the database administrator creates a user account in
the database for each user who needs access.
A) Database Authentication
B) Operating System Authentication
C) Internal Authentication
D) External Authentication
Answer: A
158. In SQL, which command is used to remove a stored function from the database?
A) REMOVE FUNCTION
B) DELETE FUNCTION
C) DROP FUNCTION
D) ERASE FUNCTION
Answer: C
159. In SQL, which command is used to select only one copy of each set of duplicate
rows
A) SELECT DISTINCT
B) SELECT UNIQUE
C) SELECT DIFFERENT
D) All of the above
Answer: A
160. Count function in SQL returns the number of
A) Values
B) Distinct values
C) Groups
D) Columns
Answer: A
161. Composite key is made up of …………….
A) One column
B) One super key
C) One foreign key
D) Two or more columns
Answer: D
162. What command is used to get back the privileges offered by the GRANT command?
A) Grant
B) Revoke
C) Execute
D) Run
Answer: B
163. Which command displays the SQL command in the SQL buffer, and then executes
it?
A) CMD
B) OPEN
C) EXECUTE
D) RUN
Answer: D
164. What is a DATABLOCK?
A) Set of Extents
B) Set of Segments
C) Smallest Database storage unit
D) Set of blocks
Answer: C

165. If two groups are not linked in the data model editor, what is the hierarchy
between them?
A) There is no hierarchy between unlinked groups.
B) The group that is right ranks higher than the group that is to right or below
it.
C) The group that is above or leftmost ranks higher than the group that is to right
or below it.
D) The group that is left ranks higher than the group that is to the right.
Answer: C

166. Which of the following types of triggers can be fired on DDL operations?
A) Instead of Trigger
B) DML Trigger
C) System Trigger
D) DDL Trigger
Answer: C

167. What operator performs pattern matching?


A) IS NULL operator
B) ASSIGNMENT operator
C) LIKE operator
D) NOT operator
Answer: C

168. In magnetic disk ________ stores information on a sector magnetically as


reversals of the direction of magnetization of the magnetic material.
a) Read–write head
b) Read-assemble head
c) Head–disk assemblies
d) Disk arm
Answer: D

169. A __________ is the smallest unit of information that can be read from or
written to the disk.
a) Track
b) Spindle
c) Sector
d) Platter
Answer: C

170. The disk platters mounted on a spindle and the heads mounted on a disk arm are
together known as ___________.
a) Read-disk assemblies
b) Head–disk assemblies
c) Head-write assemblies
d) Read-read assemblies
Answer: B
171. The disk controller uses ________ at each sector to ensure that the data is
not corrupted on data retrieval.
a) Checksum
b) Unit drive
c) Read disk
d) Readsum
Answer: A

172. _________ is the time from when a read or write request is issued to when data
transfer begins.
a) Access time
b) Average seek time
c) Seek time
d) Rotational latency time
Answer: A

173. The time for repositioning the arm is called the ________, and it increases
with the distance that the arm must move.
a) Access time
b) Average seek time
c) Seek time
d) Rotational latency time
Answer: C

174. _________ is around one-half of the maximum seek time.


a) Access time
b) Average seek time
c) Seek time
d) Rotational latency time
Answer: B

175. Once the head has reached the desired track, the time spent waiting for the
sector to be accessed to appear under the head is called the _______________.
a) Access time
b) Average seek time
c) Seek time
d) Rotational latency time
Answer: D

176. In Flash memory, the erase operation can be performed on a number of pages,
called an _______, at once, and takes about 1 to 2 milliseconds.
a) Delete block
b) Erase block
c) Flash block
d) Read block
Answer: B

177. Hybrid disk drives are hard-disk systems that combine magnetic storage with a
smaller amount of flash memory, which is used as a cache for frequently accessed
data.
a) Hybrid drivers
b) Disk drivers
c) Hybrid disk drivers
d) All of the mentioned
Answer: B
178..
Name
Annie
Bob
Callie
Derek
Which of these query will display the table given above ?
a) Select employee from name
b) Select name
c) Select name from employee
d) Select employee
Answer: C

179. Select ________ dept_name


from instructor;
Here which of the following displays the unique values of the column ?
a) All
b) From
c) Distinct
d) Name
Answer: C
180. The ______ clause allows us to select only those rows in the result relation
of the ____ clause that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
Answer: A

181. Select ID, name, dept name, salary * 1.1


where instructor;
The query given below will not give an error. Which one of the following has to be
replaced to get the desired output?
a) Salary*1.1
b) ID
c) Where
d) Instructor
Answer: C

182. The ________ clause is used to list the attributes desired in the result of a
query.
a) Where
b) Select
c) From
d) Distinct
Answer: B

183. Select name, course_id


from instructor, teaches
where instructor_ID= teaches_ID;
This Query can be replaced by which one of the following ?
a) Select name,course_id from teaches,instructor where instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name ,course_id from instructor;
d) Select course_id from instructor join teaches;
Answer: D

184. Select * from employee where salary>10000 and dept_id=101;


Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
Answer: D
185.
Employee_id Name Salary
1001 Annie 6000
1009 Ross 4500
1018 Zeith 7000
This is Employee table.
Select * from employee where employee_id>1009;
Which of the following employee_id will be displayed?
a) 1009, 1001, 1018
b) 1009, 1018
c) 1001
d) 1018
Answer: D
186. Which of the following statements contains an error?
A) Select * from emp where empid = 10003;
B) Select empid from emp where empid = 10006;
C) Select empid from emp;
D) Select empid where empid = 1009 and lastname = ‘GELLER’;
Answer: D
187. Insert into employee _____ (1002,Joey,2000);
In the given query which of the keyword has to be inserted ?
a) Table
b) Values
c) Relation
d) Field
Answer: B
188. A _____ indicates an absent value that may exist but be unknown or that may
not exist at all.
a) Empty tuple
b) New value
c) Null value
d) Old value
Answer: C
189. If the attribute phone number is included in the relation all the values need
not be entered into thephone number column . This type of entry is given as
a) 0
b) –
c) Null
d) Empty space
Answer: C
190. The predicate in a where clause can involve Boolean operations such as and.The
result of true and unknown is_______, false and unknown is _____, while unknown and
unknown is _____.
a) Unknown, unknown, false
b) True, false, unknown
c) True, unknown, unknown
d) Unknown, false, unknown
Answer: D
191. Select name
from instructor
where salary is not null;
Selects
a) Tuples with null value
b) Tuples with no null values
c) Tuples with any salary
d) All of the mentioned
Answer: B
192. In a employee table to include the attributes whose value always have some
value which of the following constraint must be used ?
a) Null
b) Not null
c) Unique
d) Distinct
Answer: B
193. Using the ______ clause retains only one copy of such identical tuples.
a) Null
b) Unique
c) Not null
d) Distinct
Answer: B
194. Create table employee (id integer,name varchar(20),salary not null);
Insert into employee values (1005,Rach,0);
Insert into employee values (1007,Ross, );
Insert into employee values (1002,Joey,335);
Some of these insert statements will produce an error. Identify the statement.
a) Insert into employee values (1005,Rach,0);
b) Insert into employee values (1002,Joey,335);
c) Insert into employee values (1007,Ross, );
d) Both a and c
Answer: C
195. The primary key must be
a) Unique
b) Not null
c) Both a and b
d) Either a or b
Answer: C

196. You attempt to query the database with this command: (25)
select nvl (100 / quantity, none)
from inventory;
Why does this statement cause an error when QUANTITY values are null?
a. The expression attempts to divide by a null value.
b. The data types in the conversion function are incompatible.
c. The character string none should be enclosed in single quotes (‘ ‘).
d. A null value used in an expression cannot be converted to an actual value
Answer: A

197. The result of _____unknown is unknown.


a) Xor
b) Or
c) And
d) Not
Answer: D
198. A relational database system needs to maintain data about the relations, such
as the schema of the relations. This is called
a) Metadata
b) Catalog
c) Log
d) Dictionary

Answer: A
199. Which of the following is another name for weak entity?
a) Child
b) Owner
c) Dominant
d) All of the mentioned
Answer: A
200. Breadth First Search is used in
a) Binary trees
b) Stacks
c) Graphs
d) Both a and c above

Answer: C
201. The____condition allows a general predicate over the relations being joined.
a) On
b) Using
c) Set
d) Where
Answer: A
202. Which of the join operations do not preserve non matched tuples.
a) Left outer join
b) Right outer join
c) Inner join
d) Natural join
Answer: C

203. Select *
from student join takes using (ID);
The above query is equivalent to
a) Select *
from student inner join takes using (ID);
b) Select *
from student outer join takes using (ID);
c) Select *
from student left outer join takes using (ID);
d) Both a and b
Answer: A

204. What type of join is needed when you wish to include rows that do not have
matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned
Answer: C
205. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned
Answer: D
206. Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
Answer: D
207. How many join types in join condition:
a) 2
b) 3
c) 4
d) 5
Answer: D
208. Which join refers to join records from the right table that have no matching
key in the left table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
Answer: B
209. The operation which is not considered a basic operation of relational algebra
is
a) Join
b) Selection
c) Union
d) Cross product
Answer: A
210. In SQL the statement select * from R, S is equivalent to
a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S
Answer: B

211. Two main measures for the efficiency of an algorithm are


a) Processor and memory
b) Complexity and capacity
c) Time and space
d) Data and space
Answer: C
212. Functional dependencies are a generalization of
a) Key dependencies
b) Relation dependencies
c) Database dependencies
d) None of the mentioned
Answer: A
213. The space factor when determining the efficiency of algorithm is measured by
a) Counting the maximum memory needed by the algorithm
b) Counting the minimum memory needed by the algorithm
c) Counting the average memory needed by the algorithm
d) Counting the maximum disk space needed by the algorithm
Answer: A

214. The Average case occur in linear search algorithm


a) When Item is somewhere in the middle of the array
b) When Item is not in the array at all
c) When Item is the last element in the array
d) When Item is the last element in the array or is not there at all
Answer: A

215. The complexity of the average case of an algorithm is


a) Much more complicated to analyze than that of worst case
b) Much more simpler to analyze than that of worst case
c) Sometimes more complicated and some other times simpler than that of worst case
d) None of the mentioned
Answer: A
316. The complexity of linear search algorithm is
a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)
Answer: B

217. The complexity of Binary search algorithm is


a) O(n)
b) O(log )
c) O(n2)
d) O(n log n)
Answer: C
218. The complexity of Bubble sort algorithm is
a) O(n)
b) O(log n)
c) O(n2)
d) O(n log n)
Answer: A
219. A __________ is a special kind of a store procedure that executes in response
to certain action on the table like insertion, deletion or updation of data.
a) Procedures
b) Triggers
c) Functions
d) None of the mentioned
Answer: C

220. Trigger are supported in


a) Delete
b) Update
c) Views
d) All of the mentioned
Answer: B
221. The CREATE TRIGGER statement is used to create the trigger. THE _____ clause
specifies the table name on which the trigger is to be attached. The ______
specifies that this is an AFTER INSERT trigger.
a) for insert, on
b) On, for insert
c) For, insert
d) Both a and c
Answer: C

222. What are the after triggers ?


a) Triggers generated after a particular operation
b) These triggers run after an insert, update or delete on a table
c) These triggers run after an insert, views, update or delete on a table
d) Both b and c
Answer: B

223. The variables in the triggers are declared using


a) –
b) @
c) /
d) /@
Answer: B

224. The default extension for an Oracle SQL*Plus file is:


a) .txt
b) .pls
c) .ora
d) .sql
Answer: B

225. Which of the following is NOT an Oracle-supported trigger?


a) BEFORE
b) DURING
c) AFTER
d) INSTEAD OF
Answer: D

226. What are the different in triggers ?


a) Define, Create
b) Drop, Comment
c) Insert, Update, Delete
d) All of the mentioned
Answer: B
227. Triggers ________ enabled or disabled
a) Can be
b) Cannot be
c) Ought to be
d) Always
Answer: A
228. Which prefixes are available to Oracle triggers?
a) : new only
b) : old only
c) Both :new and : old
d) Neither :new nor : old
Answer: C
229. Which normal form is considered adequate for normal relational database
design?
a) 2NF
b) 5NF
c) 4NF
d) 3NF
Answer: D
230. Which one of the following statements about normal forms is FALSE?
a) BCNF is stricter than 3NF
b) Lossless, dependency-preserving decomposition into 3NF is always possible
c) Lossless, dependency-preserving decomposition into BCNF is always possible
d) Any relation with two attributes is in BCNF
Answer: C
231. A table has fields F1, F2, F3, F4, and F5, with the following functional
dependencies:
F1->F3
F2->F4
(F1,F2)->F5
in terms of normalization, this table is in
a) 1NF
b) 2NF
c) 3NF
d) None of the mentioned
Answer: A
232. Which of the following is TRUE?
a) Every relation in 2NF is also in BCNF
b) A relation R is in 3NF if every non-prime attribute of R is fully functionally
dependent on every key of R
c) Every relation in BCNF is also in 3NF
d) No relation can be in both BCNF and 3NF
Answer: C
233. Consider the following functional dependencies in a database.
Date_of_Birth->Age Age->Eligibility
Name->Roll_number Roll_number->Name
Course_number->Course_name Course_number->Instructor
(Roll_number, Course_number)->Grade
The relation (Roll_number, Name, Date_of_birth, Age) is
a) In second normal form but not in third normal form
b) In third normal form but not in BCNF
c) In BCNF
d) None of the mentioned
Answer: D
234. The relation schema Student_Performance (name, courseNo, rollNo, grade) has
the following FDs:
name,courseNo->grade
rollNo,courseNo->grade
name->rollNo
rollNo->name
The highest normal form of this relation scheme is
a) 2NF
b) 3NF
c) BCNF
d) 4NF
Answer: B
235. The relation EMPDT1 is defined with attributes empcode(unique), name, street,
city, state, and pincode. For any pincode,there is only one city and state. Also,
for any given street, city and state, there is just one pincode. In normalization
terms EMPDT1 is a relation in
a) 1NF only
b) 2NF and hence also in 1NF
c) 3NF and hence also in 2NF and 1NF
d) BCNF and hence also in 3NF, 2NF and 1NF
Answer: B
236. Which one of the following statements if FALSE?
a) Any relation with two attributes is in BCNF
b) A relation in which every key has only one attribute is in 2NF
c) A prime attribute can be transitively dependent on a key in a 3 NF relation.
d) A prime attribute can be transitively dependent on a key in a BCNF relation.
Answer: D

237. Dates must be specified in the format


a) mm/dd/yy
b) yyyy/mm/dd
c) dd/mm/yy
d) yy/dd/mm
Answer: B

238. An ________ on an attribute of a relation is a data structure that allows the


database system to find those tuples in the relation that have a specified value
for that attribute efficiently, without scanning through all the tuples of the
relation.
a) Index
b) Reference
c) Assertion
d) Timestamp

Answer: A

239. Create index studentID_index on student(ID);


Here which one denotes the relation for which index is created ?
a) StudentID_index
b) ID
c) StudentID
d) Student
Answer: D

240. Which of the following is used to store movie and image files ?
a) Clob
b) Blob
c) Binary
d) Image
Answer: B

241. The user defined data type can be created using


a) Create datatype
b) Create data
c) Create definetype
d) Create type
Answer: D

242. Values of one type can be converted to another domain using which of the
following ?
a) Cast
b) Drop type
c) Alter type
d) Convert
Answer: A

243. Create domain YearlySalary numeric(8,2)


constraint salary value test __________;
In order to ensure that an instructor’s salary domain allows only values greater
than a specified value use:
a) Value>=30000.00
b) Not null;
c) Check(value >= 29000.00);
d) Check(value)
Answer: C
244. Which of the following closely resembles Create view ?
a) Create table . . .like
b) Create table . . . as
c) With data
d) Create view as
Answer: B

245. In contemporary databases the top level of the hierarchy consists of ______,
each of which can contain _____.
a) Catalogs, schemas
b) Schemas, catalogs
c) Environment, schemas
d) Schemas, Environment
Answer: A

246. Which of the following statements creates a new table temp instructor that has
the same schema as instructor.
a) create table temp_instructor;
b) Create table temp_instructor like instructor;
c) Create Table as temp_instructor;
d) Create table like temp_instructor;

Answer: B
247. To include integrity constraint in a existing relation use :
a) Create table
b) Modify table
c) Alter table
d) Drop table
Answer: C

248. Which of the following is not a integrity constraint ?


a) Not null
b) Positive
c) Unique
d) Check ‘predicate’
Answer: B

249. Create table Manager(ID numeric,Name varchar(20),budget numeric,Details


varchar(30));
Inorder to ensure that the value of budget is non-negative which of the following
should be used?
a) Check(budget>0)
b) Check(budget<0) c) Alter(budget>0)
d) Alter(budget<0) [expand title=""]
Answer: D
250. Foreign key is the one in which the ________ of one relation is referenced in
another relation.
a) Foreign key
b) Primary key
c) References
d) Check constraint
Answer: B
251. Create table course ( . . . foreign key (dept name) references
department . . . ); Which of the following is used to delete the entries in the
referenced table when the tuple is deleted in course table?
a) Delete
b) Delete cascade
c) Set null
d) All of the mentioned
Answer: B
252. Domain constraints, functional dependency and referential integrity are
special forms of _________.
a) Foreign key
b) Primary key
c) Assertion
d) Referential constraint
Answer: C
253. Which of the following is the right syntax for assertion?
a) Create assertion 'assertion-name' check 'predicate';
b) Create assertion check 'predicate' 'assertion-name';
c) Create assertions 'predicates';
d) All of the mentioned
Answer: A

254. Data integrity constraints are used to:


a) Control who is allowed access to the data
b) Ensure that duplicate records are not entered into the table
c) Improve the quality of data entered for a specific property (i.e., table column)
d) Prevent users from changing the values stored in the table
Answer: C
255. Which of the following can be addressed by enforcing a referential integrity
constraint?
a) All phone numbers must include the area code
b) Certain fields are required (such as the email address, or phone number) before
the record is accepted
c) Information on the customer must be known before anything can be sold to that
customer
d) When entering an order quantity, the user must input a number and not some text
(i.e., 12 rather than ‘a dozen’)
Answer: C

256. _____________ can help us detect poor E-R design.


a) Database Design Process
b) E-R Design Process
c) Relational scheme
d) Functional dependencies
Answer: D
257. If a multivalued dependency holds and is not implied by the corresponding
functional dependency, it usually arises from one of the following sources.
a) A many-to-many relationship set
b) A multivalued attribute of an entity set
c) A one-to-many relationship set
d) Both a and b

Answer: D
258. Which of the following has each related entity set has its own schema and
there is an additional schema for the relationship set.
a) A many-to-many relationship set
b) A multivalued attribute of an entity set
c) A one-to-many relationship set
d) Both a and b

Answer: A
259. In which of the following , a separate schema is created consisting of that
attribute and the primary key of the entity set.
a) A many-to-many relationship set
b) A multivalued attribute of an entity set
c) A one-to-many relationship set
d) Both a and b
Answer: B

260. Suppose the user finds the usage of room number and phone number in a
relational schema there is confusion.This is reduced by
a) Unique-role assumption
b) Unique-key assignment
c) Role intergral assignment
d) None of the mentioned

Answer: A

261. What is the best way to represent the attributes in a large database?
a) Relational-and
b) Concatenation
c) Dot representation
d) All of the above
Answer: B

262. Designers use which of the following to tune performance of systems to support
time-critical operations?
a) Denormalization
b) Redundant optimization
c) Optimization
d) Realization
Answer: A
263. In the schema (dept name, size) we have relations total inst 2007, total inst
2008 . Which dependency have lead to this relation ?
a) Dept name, year->size
b) Year->size
c) Dept name->size
d) Size->year

Answer: A

264. Relation dept year(dept name, total inst 2007, total inst 2008, total inst
2009) .Here the only functional dependencies are from dept name to the other
attributes .This relation is in
a) Fourth NF
b) BCNF
c) Third NF
d) Second NF

Answer: B

265. Thus a _______ of course data gives the values of all attributes, such as
title and department, of all courses at a particular point in time.
a) Instance
b) Snapshot
c) Both a and b
d) All of the mentioned

Answer: B

266. Representations such as the in the dept year relation, with one column for
each value of an attribute, are called _______; they are widely used in
spreadsheets and reports and in data analysis tools.
a) Cross-tabs
b) Snapshot
c) Both a and b
d) All of the mentioned

Answer: A

267. Which one of the following is used to define the structure of the
relation ,deleting relations and relating schemas ?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema

Answer: B
268. Which one of the following provides the ability to query information from the
database and to insert tuples into, delete tuples from, and modify tuples in the
database ?
a) DML(Data Manipulation Langauge)
b) DDL(Data Definition Langauge)
c) Query
d) Relational Schema

Answer: A

269. Create table employee (name varchar ,id integer)


What type of statement is this ?
a) DML
b) DDL
c) View
d) Integrity constraint
Answer: B

270. Select * from employee


What type of statement is this?
a) DML
b) DDL
c) View
d) Integrity constraint

Answer: A
271. The basic data type char(n) is a _____ length character string and varchar(n)
is _____ length character.
a) Fixed, equal
b) Equal, variable
c) Fixed, variable
d) Variable, equal
Answer: C

272. An attribute A of datatype varchar(20) has the value “Avi” . The attribute B
of datatype char(20) has value ”Reed” .Here attribute A has ____ spaces and
attribute B has ____ spaces .
a) 3, 20
b) 20, 4
c) 20 , 20
d) 3, 4

Answer: A

273. To remove a relation from an SQL database, we use the ______ command.
a) Delete
b) Purge
c) Remove
d) Drop table

Answer: D

274. Delete from r; r – relation


This command performs which of the following action ?
a) Remove relation
b) Clear relation entries
c) Delete fields
d) Delete rows
Answer: B

275. Insert into instructor values (10211, ’Smith’, ’Biology’, 66000);


What type of statement is this ?
a) Query
b) DML
c) Relational
d) DDL

Answer: B

276. Updates that violate __________ are disallowed .


a) Integrity constraints
b) Transaction control
c) Authorization
d) DDL constraints

Answer: A

277. Having clause is processed after the GROUP BY clause and any aggregate
functions.

A) True
B) False
Answer: A
278. In the context of MS SQL SERVER, with the exception of ............ column(s),
any column can participate in the GROUP BY clause.
A) bit
B) text
C) ntext
D) image
E) All of above
Answer: E
279. The sequence of the columns in a GROUP BY clause has no effect in the ordering
of the output.

A) True
B) False
Answer: B
280. You want all dates when any employee was hired. Multiple employees were hired
on the same date and you want to see the date only once.

Query - 1
Select distinct hiredate
From hr.employee
Order by hiredate;
Query - 2
Select hiredate
From hr.employees
Group by hiredate
Order by hiredate;
Which of the above query is valid?

A) Query - 1
B) Query - 2
C) Both
Answer: C
281. GROUP BY ALL generates all possible groups - even those that do not meet the
query's search criteria.

A) True
B) False
Answer: A
282. All aggregate functions ignore NULLs except for ............

A) Distinct
B) Count (*)
C) Average()
D) None of above
Answer: B
283. Using GROUP BY ............ has the effect of removing duplicates from the
data.

A) with aggregates
B) with order by
C) without order by
D) without aggregates
Answer: D
284. Below query is run in SQL Server 2012, is this query valid or invalid:
Select count(*) as X
from Table_Name
Group by ()
A) Valid
B) Invalid
Answer: A
285. For the purposes of ............, null values are considered equal to other
nulls and are grouped together into a single result row.

A) Having
B) Group By
C) Both of above
D) None of above
Answer: B
286. If you SELECT attributes and use an aggregate function, you must GROUP BY the
non-aggregate attributes.

A) True
B) False
Answer: A

287. GRANT ALTER ON SERVER ROLE::Production TO Jim ;

A) The above example allows Jim to add other permissions to the user-defined server
role named Production.
B) The above example allows Jim to add other roles to the user-defined server role
named Production.
C) The above example allows Jim to add other logins to the user-defined server role
named Production.
D) None of above.
Answer: C
288. The CONTROL SERVER and ALTER ANY SERVER ROLE permissions are sufficient to
execute ALTER SERVER ROLE for a fixed server role.

A) True
B) False
Answer: B
289. The following statement returns all Database Engine permissions.

A) SELECT * FROM fn_builtin_permissions (default);


B) SELECT * FROM fn_inbuilt_permissions (default);
C) SELECT * FROM fn_build_permissions (default);
D) SELECT * FROM fn_built_in_permissions (default);
Answer: A
290. Permissions at the schema level can be granted and users the automatically
inherit permissions on new objects created in the schema.

A) True
B) False
Answer: A
291. DENY revokes a permission so that it cannot be inherited. DENY takes
precedence over all permissions, except DENY does not apply to .......

A) user defined strict permissions


B) object owners
C) members of sysadmin
D) nested roles
Answer: BC
292. What Permissions do I have on the DB I am Connected to?

A) SELECT * FROM fn_all_permissions (NULL, 'DATABASE');


B) SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
C) SELECT * FROM fn_permissions (NULL, 'DATABASE');
D) SELECT * FROM fn_ST_permissions (NULL, 'DATABASE');
Answer: B
293. Roles can be nested; Permission sets that are assigned to roles are inherited
by ........ members of the role.

A) elected
B) restricted
C) admin
D) all
Answer: D
294. Members of the sysadmin fixed server role and object owners cannot be denied
permissions.

A) True
B) False
Answer: A
295. The permissions granted to logins and user-defined fixed server roles can be
examined by using the ....... view.

A) sys.credentials
B) sys.server_role_members
C) sys.server_permissions
D) None of above
Answer: C
296. Users with the ........ permission can create new user-defined database roles
to represent groups of users with common permissions.

A) CREATE CERTIFICATE
B) CREATE CONTRACT
C) CREATE LOGIN
D) CREATE ROLE
Answer: D

297. In SQL Server 2012, the merge join does not need any equijoin predicate.

A) True
B) False
Answer: B
298. A merge join can be . . . . .

A) many-to-one
B) many-to-many
C) one-to-one
D) one-to-many
Answer: BD
299. Inputs to the merge join may or may not be sorted on the join keys.

A) True
B) False
Answer: B
300. With a merge join each table is read at most once, and the total cost is
proportional to the . . . . . of the number of rows in the inputs. Thus, merge join
is often a better choice for larger inputs.

A) proportion
B) product
C) sum
D) none of above
Answer: C
301. Merge joins support all outer and semi-join variations.
A) True
B) False
Answer: A
302. SQL Server can get sorted inputs for a merge join in two ways: It can
explicitly sort the inputs using a sort operator or it can read the rows from an
index. In general, a plan using an index to achieve sort order is . . . . . . than
a plan using an explicit sort.

A) cheaper
B) costlier
C) sometimes cheaper and sometimes costlier
D) none of above
Answer: A
303. A merge join necessarily need to scan every row from both inputs. As soon as
it reaches the end of either input, the merge join stops scanning.

A) True
B) False
Answer: B
304. Merge join supports multiple equijoin predicates as long as the inputs are
sorted on . . . . . . the join keys.

A) some of
B) one of
C) all
D) none of above
Answer: C
305. Merge join supports a special case where in some cases, the optimiser
generates a merge join for a full outer join, even without an equijoin predicate.

A) True
B) False
Answer: A
306. Merge join itself is generally slow, but it can be an expensive choice if sort
operations are required.

A) True
B) False
Answer: B
307. Hash join is designed to handle large . . . . inputs.

A) sorted
B) unsorted
Answer: B
308. Hash joins are used for many types of set-matching operations such
as . . . . .

A) intersection
B) inner join
C) left, right, and full outer join
D) both A & B
E) all of above
Answer: E
309. When an in-memory hash join is not possible, the Hash Warning is fired. The
idea behind this event is that grace hash join and recursive hash joins are . . . .
efficient and that the DBA should be aware of this.

A) more
B) equally
C) less
D) none of above
Answer: C
310. There are 3 different types of hash joins . . . . . .

A) in-memory, grace hash join and cursive hash join


B) in-memory, trace hash join and recursive hash join
C) out-memory, grace hash join and recursive hash join
D) in-memory, grace hash join and recursive hash join
Answer: D
311. Hash join requires an equality predicate.

A) True
B) False
Answer: A
312. There are three SQLTrace events that fire in response to hash spills, sort
spills and exchange spills. They are ......

A) hashed warnings, sorted warnings and exchanged warnings


B) H warnings, S warnings and E warnings
C) hash warnings, sort warnings and exchange warnings
D) hash-spill warnings, sort-spill warnings and exchange-spill warnings
Answer: C
313. The term . . . . is sometimes used to describe grace hash joins or recursive
hash joins.

A) Spill bailout
B) Join bailout
C) Spill Warning bailout
D) Hash bailout
Answer: D
314. Hash join performs its operations in 2 phases . . . . . .

A) initial phase and probe phase


B) init phase and probe phase
C) build phase and probe phase
D) build phase and problem phase
Answer: C
315. It is not always possible during optimization to determine which hash join is
used. Therefore, SQL Server starts by using an in-memory hash join and gradually
transitions to grace hash join, and recursive hash join, depending on the size of
the build input.

A) True
B) False
Answer: A
316. A . . . . . . is a join method that used elements of both a simple in-memory
hash and grace hash.

A) combined join
B) hybrid join
C) team join
Answer: B

317. A columnstore index is a technology for storing, retrieving and managing data
by using a columnar data format, called a . . . . . . .

A) column segment
B) deltastore
C) columnstore
D) columnar
Answer: C
318. As an example, if a table has 50 columns and the query only uses 5 of those
columns, the columnstore index only fetches the . . . . . columns from disk. It
skips reading in the other . . . . . . columns.

A) 5, 45
B) 45, 5
C) 10, 40
D) 40, 10
Answer: A
319. A nonclustered columnstore index and a clustered columnstore index function
the same. The difference is a nonclustered index is a secondary index created on
a . . . . . . . table, whereas a clustered columnstore index is the primary storage
for the . . . . . . . table.

A) columnstore, entire
B) rowstore, entire
C) rowstore, columnstore
D) columnstore, rowstore
Answer: B
320. Columnstore indexes read compressed data from disk, which means fewer bytes of
data need to be read into memory.

A) True
B) False
Answer: A
321. Columnstore indexes give high performance gains . . . . . . . . .

A) for analytic queries that scan large amounts of data, especially on large tables
B) for queries on a small range of values
C) in case of fact tables, since they tend to require full table scans rather than
table seeks
D) Both A & C
Answer: D
322. Clustered columnstore indexes collect up to 1,048,576 rows in deltastore
before compressing them into the compressed rowgroup. Once the rowgroup contains
1,048,576 rows, the delta rowgroup is marked closed . . . .

A) but it is still available for queries and update/delete operations but the newly
inserted rows go into an existing or newly created deltastore rowgroup.
B) and is not available for queries and update/delete operations. The newly
inserted rows go into an existing or newly created deltastore rowgroup.
C) and is not available for queries and update/delete operations. The new rows
cannot be inserted.
D) but it is still available for queries and update/delete operations but the new
rows cannot be inserted.
Answer: A
323. The memory required for creating a columnstore index depends on
the . . . . . . .

A) number of columns
B) number of string columns
C) DOP
D) Both A & B
E) All of above
Answer: A
324. If your table has fewer than one million rows, SQL Server will use only one
thread to create the columnstore index.

A) True
B) False
Answer: A
325. By design, a columnstore table . . . . . . . a primary key constraint.

A) allows
B) does not allow
Answer: B
326. Because data in a columnstore index is grouped by columns, rather than by
rows, data can be compressed as efficiently as with rowstore indexes.

A) True
B) False
Answer: B

327.Below statement is true or false:


In order to execute INSERT statements, a user must have at least the INSERT
permission assigned on the target table.

A) True
B) False
Answer: A
328.SQL Server can automatically provide values for ......

A) nullable columns
B) IDENTITY columns
C) columns with the timestamp data type
D) columns with a default value
E) All of above
F) None of above
Answer: E
329.Which of the following insert statements are correct:

A)
INSERT INTO Persons ('xxx1','yyy1');
B)
INSERT INTO [dbo].[Persons]
([LastName],
[FirstName]
)
VALUES ('xxx',
'yyy'
);
C)
INSERT INTO Persons VALUES ('xxx1','yyy1');
D)
INSERT INTO Persons VALUE ('xxx1','yyy1');
Answer: BC
330.In SQL Server, you use the INSERT statement to add one new row and not multiple
new rows to an existing table.

A) True
B) False
Answer: B
331. You can insert data into a table from the results of the EXECUTE statement.

A) True
B) False
Answer: A
332. You can use the INSERT statement to insert data into a .......

A) particular column
B) all columns
C) IDENTITY columns
D) All of above
E) None of above
Answer: D
333.SQL Server supports several methods for inserting data into tables
including ........

A) SELECT INTO
B) BULK SELECT INSERT
C) INSERT SELECT
D) INSERT SELECT FROM OPENROWSET(BULK …)
Answer: ACD
334. Which of the below statement/statements is correct if we need to insert
multiple values with one insert query:
1. INSERT INTO Persons VALUES ('xxx1','yyy1'), ('xxx2','yyy2'), ('xxx3','yyy3');
2. INSERT INTO Persons VALUES ('xxx1','yyy1'), VALUES ('xxx2','yyy2'),
Values ('xxx3','yyy3');
A) only 1 is correct
B) only 2 is correct
C) Both are correct
D) None is correct
Answer: A
335. Tick the statements which are true.
It is always a good idea to provide a full-column list for INSERT statement because
if the full-column list is not specified then

A) SQL SERVER generates an error


B) SQL Server resolves full-column lists whenever the INSERT statement executes
C) INSERT statement can insert the data in different table then specified
D) INSERT statement may generate an error if the underlying table schema changes
Answer: BD
336. If during Insert you want to specify the number or percent of random rows that
will be inserted then you can use the . . . . . expression.

A) TYPE
B) NUMBER
C) TOP
D) PERCENT
Answer: C

337. SQL Server supports two types of CTEs:

A) indexed and nonindexed


B) recursive and nonrecursive
C) with view and without views
D) None of above
Answer: B
338. You cannot reference .............. clause in a select statement for a CTE
unless the statement also includes a TOP clause.

A) Update
B) Where
C) an ORDER BY
D) DISTINCT
Answer: C
339. If you need to reference/join the same data set multiple times, then CTE is
not the choice.

A) True
B) False
Answer: B
340. You can use a CTE within a CREATE VIEW statement.

A) True
B) False
Answer: A
341. SELECT statements within recursive CTEs cannot contain which of the following:

A) The DISTINCT Keyword


B) The TOP keyword
C) GROUP BY or Having clauses
D) All of above
Answer: D
342. CTEs are unindexable but on the other hand CTEs can use existing indexes on
referenced objects.

A) True
B) False
Answer: A
343. CTE is different from view in a way that CTE is not created as ..............
in the database and therefore is only available for this single statement.

A) Table
B) Link
C) Procedure
D) an object
Answer: D
344. CTEs rely on stats of the ................... as CTEs do not have dedicated
stats of their own.

A) system Tables
B) static views
C) underlying objects
D) None of above
Answer: C
345. Tables which are on the remote servers cannot be referenced in the CTE.

A) True
B) False
Answer: B
346. A CTE can reference itself and previously defined CTEs in the same WITH
clause.

A) True
B) False
Answer: A

347. Which logical method can be used in SQL Server 2012 to returns an item from
the specified index in a list of values?

a) SELECT
b) SELECTION
c) CHOOSE
d) None of the above
Answer: C
348. RAND () method can be used for:

a) Executing the query randomly.


b) gives a pseudo-random float value
c) return values randomly
d) All of the above
Answer: B
349. A method in SQL server which is also called as arcsine?

a) ASIN
b) ASINE
c) SIN
d) None of the above
Answer: A
350. What will an IIF() method of SQL server 2012 do in a query?

a) Nothing
b) It will return 1 of 2 values supplied as parameters and depends on whether the
Boolean parameter evaluates to true or false.
c) It works inside the IF statement
d) None of the above.
Answer: B
351. What is the significance of LEFT method in SQL server 2012?

a) Executes left query in joins


b) There is no method called LEFT in SQL Server.
c) It gives the left part of a character input string with the mentioned no. of
characters.
d) None of the above
Answer: C
352. Which function in SQL server is used to insert a string into another string?

a) FILL
b) STUFF
c) MERGE
d) None of the above
Answer: B
353. What is the purpose of CAST function in SQL server?

a) It converts or casts an expression of 1 data type to another.


b) It cannot be in SQL Server
c) Add description to statement
d) None of the above
Answer: A
354. Is there any function in SQL server which can be used to check whether value
can be Casted or not? If yes, name it.

a) No there is no method
b) Try_Cast
c) CAST
d) None of the above
Answer: B
356. What is the purpose of MIN function in SQL Server?

a) It returns the minimum value in the expression


b) It is use for decrementing the integer value
c) MIN is not a SQL server function
d) None of the above
Answer: A
357. Which function in SQL server is used in query to find the count of the items
in the concerned object (i.e. table, view, etc.)?

a) COUNTER
b) COUNT
c) DETECT
d) None of the above
Answer: B
358. A nonclustered index greatly affect the ordering and storing of the data.

A) True
B) False
Answer: B
359. Full-text indexes are created using the

A) Create Index
B) Create Fulltext Index
C) Special System Stored Procedures
D) Both b & c
Answer: D
360. A ................ index is one which satisfies all requested columns in a
query without performing a further lookup into the clustered index.

A) Clustered
B) Non-Clustered
C) Covering
D) B-tree
Answer: C
361. Each database can have only one clustered index.

A) True
B) False
Answer: A
362. While creating an index on a column(s) in MS SQL Server you can specify that
the index on each column be either ascending or descending and this affects the
performance.

A) True
B) False
Answer: A
362. In a ..................., the first row added to the indexis the first record
in the table, the second row is the second record in the table and so on.

A) Clustered
B) Non-Clustered
C) Heap
D) CharIndex
Answer: C
364. In ........... index, instead of storing all of the columns for a record
together, each column is stored separately with all of the other rows in an index.

A) Clustered
B) Column Store
C) Non-Clustered
D) Row Store
Answer: B
365. Without primary key, the creation of spatial index will not succeed.

A) True
B) False
Answer: A
366. If an index is ............................. the metadata and statistics
continue to exist.

A) disabling
B) dropping
C) altering
D) Both a & b
Answer: A
367. Index rebuild and index reorganize is one and the same thing.

A) True
B) False
Answer: B
368. You can instruct SQL Server to use a specific JOIN type by using the . . . . .

A) Query hints
B) Join hints
C) Table hints
D) All of above
Answer: B
369. For Joint type "nested loop" Join hint is . . . . . .

A) Remote join
B) Hash Join
C) Loop Join
D) Merge Join
Answer: C
370. The . . . . . hint dictates that the join operation is performed on the server
hosting the right table.

A) Remote join
B) Hash Join
C) Loop Join
D) Merge Join
Answer: A
371. For simple queries affecting a small result set, the loop join generally
provides better performance than a hash or merge join.

A) True
B) False
Answer: A
372. You cannot specify join hints when you use the ANSI-style join syntax - that
is, when you actually use the keyword JOIN in the query.

A) True
B) False
Answer: B
373. It is possible to specify more than one join type in the query hint and allow
SQL Server to choose the least-expensive one.

A) True
B) False
Answer: A
374. A . . . . hint takes precedence over a . . . . hint if both are specified.
A) query, join
B) join, query
Answer: B
375. The Remote join, that is used when dealing with data from a remote server has
serious affects on execution plans.

A) True
B) False
Answer: B
376. Use a REMOTE join hint only when the . . . . table has fewer rows than the . .
. . table.

A) left, right
B) right, left
Answer: A
377. . . . . . specifies that the join order indicated by the query syntax is
preserved during query optimization.

A) KEEP PLAN
B) MAX_GRANT_PERCENT
C) FORCE ORDER
D) EXPAND VIEWS
Answer: C

376. An ORDER BY can be used in a subquery.

A) True
B) False
Answer: B
379. The subquery is known as a ................. subquery because the subquery is
related to the outer SQL statement.

A) Relational
B) Related
C) Correlated
D) Corelational
Answer: C
380. A subquery can itself include one or more subqueries. ..............
subqueries can be nested in a statement.

A) 16
B) 32
C) 64
D) Any number of
Answer: D
381. In case of correlated subquery the outer query is executed once. The subquery
is executed ............. for every row in the outer query.

A) Once
B) Twice
C) Thrice
D) Both A & B
Answer: A
382. The SELECT query of a subquery is always enclosed in parentheses and may only
include an ORDER BY clause only when a TOP clause is also specified.

A) True
B) False
Answer: A
383. Below subquery is valid or invalid:

Select (Select 5) As MySubQueryValue;

A) Valid
B) Invalid
Answer: A
384. There cannot be a subquery which is independent of the outer query.

A) True
B) False
Answer: B
385. Below is an example of

SELECT a.EmployeeID
FROM HumanResources.Employee a
WHERE a.ContactID IN
(
SELECT b.ContactID
FROM Person.Contact b
WHERE b.Title = 'Mrs.'
)
GO
A) Correlated Subquery
B) Noncorrelated Subquery
Answer: B
386. If a table appears only in a subquery and not in the outer query, then columns
from that table can be included in the output.

A) True
B) False
Answer: B
387. A subquery can be used anywhere an expression is allowed.

A) True
B) False
Answer: A

388. The ................. statement is used to create a table in a database.

A) CREATE SQL TABLE


B) CREATE TABLE
C) CREATE SQL.TABLE
D) Both B and C
Answer: B
389. #table refers to a local temporary table and is visible to only the user who
created it.

A) True
B) False
Answer: A
390. Which command to use in order to delete the data inside the table, and not the
table itself
Answer: B
A) DELETE
B) TRUNCATE
C) Both TRUNCATE & DELETE
D) DROP
Answer: B
391. Transaction rollbacks affect Table variables

A) True
B) False
Answer: B
392. ##table refers to a ............. which is visible to all users.

A) table variables
B) persistent temporary tables
C) local temporary tables
D) global temporary table
Answer: D
393. Delete table and Drop table are not the same though. The ......... will delete
all data from the table whilst the ....... will remove the table from the database.

A) Drop,Delete
B) Delete, Drop
Answer: B
394. Below Query shows:
USE DBName
GO
SELECT *
FROM sys.Tables
GO
A) List of system tables of Database
B) List of temporary tables of Database
C) List of all tables of Database
D) Both A & B
Answer: C
395. sp_tables returns only the views in the database.

A) True
B) False
Answer: B
396. In order to modify system tables you can use:
A) sp_configure
B) sp_modify
C) sp_allow_updates
D) Both A & B
Answer: A
397. ......... and ......... system tables maintain entries containing object
definitions and other tracking information for each object.

A) sysobjects
B) syscomments
C) systrack
D) Both A & B
Answer: D

398. What is the basic syntax for Delete query?

a) Delete * from tablename;


b) Delete from tablename;
c) Delete column1, Column2, column(n) from tablename;
d) All are correct.
Answer: B
399. Which clause in DELETE statement leads to perform delete with certain
criteria?
a) Group
b) Group By
c) Where
d) Having
Answer: C
400. Is TOP used in Delete Query?

a) True
b) False
Answer: A
401. Which category Delete query exits?

a) DDL
b) DML
c) TCL
d) BPL
Answer: B
402. Does delete statement maintains lock?

a) True
b) False
Answer: A
403. Delete statements locks whole Table or a single Row at a time?

a) Delete never locks any table or row.


b) Delete never locks any row while deleting.
c) Delete locks only Row.
d) Delete locks both Row and table.
Answer: C
404. If a column in a table is set to an Identity and if user deletes the row from
the table with the help of Delete statement. Will this resets Identity value for
the table?

a) Delete never retain Identity


b) Delete never recognizes identity
c) Delete retain identity value
d) None of the above
Answer: C
405. Out of the below constraints which one is applicable on Delete query?

a) Row level constraints


b) Page level constraints
c) Table Level constraints
d) None of the above.
Answer: A
406 Can delete be used with Views?

a) Yes (with some limitations)


b) Yes (fully)
c) Can never be used with Views.
Answer: A
407. Does delete statement enables triggers?

a) Yes
b) No
Answer: A

408. Which category Delete query exits?


a) DDL
b) DML
c) TCL
d) BPL
Answer: A
409. Can we use Where condition in Truncate?

a) True
b) False
Answer: A
410. What is not true about truncate?

a) Truncate delete the record from the table


b) Truncate fires trigger after deleting the record
c) Truncate is used to delete a record
d) It runs trigger after deletion
Answer: D
411. Does Truncate maintain log?

a) True
b) False
Answer: B
412. Which one is faster to delete a table?

a) Truncate
b) Delete
c) Remove
d) None of the above
Answer: A
413. What are the restrictions while using Truncate?

a) Foreign Key only,


b) No restrictions
c) Foreign key, participation in indexed view
d) None of the above
Answer: C
414. Does truncate retain Identity?

a) Never retains Identity


b) Reset to the seed value
c) No Change on Identity
d) None of the above
Answer: B
415. Truncate statement locks whole Table or a single Row at a time?

a) Both
b) Only Row
c) Table
d) None of the above
Answer: C
416. Can Truncate be used in Views?

a) True
b) False
Answer: B
417. What is true about truncate with Foreign key?

a) It will delete the rows from both the tables (child as well as parent)
b) It will not delete even if CASCADE ON DELETE option is given with parent table
c) It will delete even if CASCADE ON DELETE option is given with parent table
d) All are true
Answer: B
418. TRUNCATE can’t be used if you have Replication/ CDC enabled for the table, is
it true?

a) True
b) False
Answer: A

419. Which one is not applicable while querying on a view?

a) From
b) SELECT
c) Order By
d) Where
Answer: C
420. Can we create Clustered Index with Count (*) in a view?

a) True
b) False
Answer: B
421. Refer below query which leads to create a view named vwEmployee.

CREATE vwEmployee VIEW


AS
SELECT nothing
FROM dbo.Employee
WHERE ID < 100
Now, tell the problem in query?
a) Above query is correct.
b) View name must be after keyword view and ‘nothing’ is not a keyword , so should
be replaced with *.
c) Replace nothing with view name.
d) Replace nothing with column names.
Answer: B
422. A view always fetch up to date data from the table because it runs it’s query
each time it receives a call, is this statement correct?

a) True
b) False
Answer: A
423. IN SQL Server, can we Create Partitioned Views?

a) True
b) False
Answer: A
424. How can you drop more than one View in single command?

a) Drop viewname1 + viewname2 + viewname(n);


b) Drop viewname1; Drop viewname2; Drop viewname(n);
c) Drop viewname1; viewname2; viewname(n);
d) Drop viewname1, viewname2,viewname(n);
Answer: D
425. What is true about views among all the given below statements:

a) View never references actual table for which it is created.


b) View can’t use JOIN in it’s query.
c) The performance of the view degrades if they are based on other views.
d) Only option to safeguard data integrity.
Answer: C
425. Can we show computed values in views from different columns of a table?

a) Yes
b) No
Answer: A
426. Views are also called as:

a) Complex tables
b) Simple tables
c) Virtual tables
d) Actual Tables
Answer: C
427. Are views stored in Databases?

a) Yes
b) No
Answer: A

428. Which of the following is not a Key in SQL Server?

a) Primary
b) Foreign
c) Alternate
d) Secondary
Answer: D
429. Can a column with Primary Key have Null value?

a) True
b) False
Answer: B
430. How can a SQL developer add a key on a table?

a) While creating a table


b) With Alter table command
c) With SQL server Properties window (by right clicking on a table)
d) All of the above
e) None of the above
Answer: D
431. Can a key created on a table be Dropped?

a) True
b) False
Answer: A
432 A Key which is a set of one or more columns that can identify a record uniquely
is called?

a) Natural key
b) Candidate key
c) Not Null key
d) Alternate key
Answer: B
433. What is true about Unique and primary key?

a) Unique can have multiple NULL values but Primary can’t have.
b) Unique can have single NULL value but Primary can’t have even single.
c) Both can have duplicate values
d) None of the above
Answer: B
434. Can a table have more than one foreign key?

a) True
b) False
Answer: A
435. By default, which key creates Clustered index?

a) Foreign Key
b) Unique Key
c) Primary Key
d) None of the above
Answer: C
436. Which key accepts multiple NULL values?

a) Foreign Key
b) Unique Key
c) Primary Key
d) None of the above
Answer: A
437. Can column with Unique key have duplicate values?

a) True
b) False
Answer: B
438.. While using the IN operator, the SQL engine will scan all records fetched
from the inner query.

A) True
B) False
Answer: A
439. Consider the below table.

Table tab_1:
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya
NULL NULL NULL
0 0 0

What is the result of the below query:

select * from tab_1


where '0' in (select ID from Tab_1 where ID in (0))

A)
ID Column_2 Name
0 0 0

B)
ID Column_2 Name
NULL NULL NULL

C)
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya
NULL NULL NULL
0 0 0

D)None of above
Answer: C
440.. The select list of a subquery introduced by EXISTS almost always consists of
………. There is no reason to list column names as you are just verifying whether rows
that meet the conditions specified in the subquery exist.

A) percent (%)
B) asterisk (*)
C) Comma (,)
D) None of above
Answer: B
441. Only EXISTS can be prefixed with NOT but IN cannot be.

A) True
B) False
Answer: B
442. When EXISTS is used, SQL Server stops as soon as it finds .......... record
that matches the criteria.

A) Middle
B) Last
C) One
D) None of above
Answer: C
443. NOT EXISTS works like EXISTS, except the WHERE clause in which it is used is
satisfied if ........... rows are returned by the subquery.

A) Two
B) Unpinned
C) TOP
D) No
D
444. The keyword EXISTS is not preceded by a ............

A) constant
B) column name
C) other expression
D) All of above
Answer: D
445. Consider the below table.

Table dbo.tab_1
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya

What is the result of the below query:


DECLARE @InList varchar(100)
SET @InList = '11,12,33,44'

SELECT *
FROM Tab_1
WHERE ','+@InList+',' LIKE ',%'+CAST(Id AS varchar)+',%'

A)
ID Column_2 Name
11 F1 Fardeen
33 H1 Harish
44 I1 Fardeen

B)
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen

C)
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya

D) None of above
Answer: A
446. Consider the below table.

Table tab_1
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya
NULL NULL NULL

What will be the result of following query:

SELECT ID, column_2, Name


FROM dbo.tab_1
WHERE EXISTS (SELECT NULL)

A)
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya

B) It will show an error message.

C)
ID Column_2 Name
NULL NULL NULL

D)
ID Column_2 Name
11 F1 Fardeen
22 G1 Gautam
33 H1 Harish
44 I1 Fardeen
55 E1 Eklavya
NULL NULL NULL
Answer: D
457. Exists uses a ............ to join values from a column to a column within the
subquery.

A) View
B) Join
C) Subquery
D) Clustered Index
Answer: B

448. Which one is correct syntax for Insert Statement?

a) Insert table_name Columns(Col1, Col2,Col3);


b) Insert into table_name (Col1, Col2,Col3) VALUES (Val1,Val2,Val3);
c) Insert Columns(Col1, Col2,Col3) VALUE (Val1, Val2,Val3) Into table_name;
d) None of the above
Answer: B
449. Can the sequence & number of columns and values be different in an Insert
statement?

a) True
b) False
Answer: B
How is Column wise insertion of data different from simply passing values to a
table?

a) Column wise data leads in populating data on optional basis i.e. whether user
wanted to insert data in a column or not.
b) We can’t pass value to a table without mentioning column names in an insert
statement.
c) Passing values to a table without column names is always safe.
d) None of the above.
Answer: A
450 Update statement is used to insert values in a table and therefore it is a
replacement of insert statement, is it correct?

a) True
b) False
Answer: B
451. Which one is correct syntax for Update Statement?

a) Update Table table_name Columns(Col1, Col2,Col3);


b) Update into table_name (Col1, Col2,Col3) VALUES (Val1,Val2,Val3);
c) Update table_name Set Col_name=Value;
d) None of the above
Answer: C
452. Is mentioning column name corresponding to its value mandatory in Update
Statement?
a) True
b) False
Answer: A
453. What will be the consequence of omitting ‘Where’ clause in Update Statement?

a) No effect on the query as well as on table.


b) All records present in the table will be updated
c) Only one record will be updated
d) None of the above
Answer: B
454. In any case, can update statement be used in place of insert statement?

a) Yes, if record exists with Identity value.


b) Yes, in every case
c) No, it is not possible at all.
d) None of the above.
Answer: A
455. Can insert be used in place of update?

a) True
b) False
c) It is replacement of update
d) None of the above
Answer: B
456. Can we use ‘where’ clause in an Insert statement?

a) True
b) False
Answer: B

457. Which one is correct syntax for Where clause in SQL server?

a) SELECT WHERE "Condition" Col1, Col2 FROM "Table" ;


b) SELECT "Condition" Col1, Col2 FROM "Table" WHERE;
c) SELECT Col1, Col2 FROM "Table" WHERE "condition";
d) None of the above
Answer: C
558. What can be the condition in where clause in a SQL query?

a) Condition that is to be met for the rows to be returned from result.


b) Boolean Condition only
c) Text condition only
d) None of the above
Answer: A
459. Is there any limit for number of predicates/conditions to be added in a Where
clause?

a) True
b) False
Answer: B
460. What is the purpose of Order By Clause in SQL server?

a) It is used to sort the result.


b) It is used to change sequence order of columns
c) It can’ be used in SQL Server
d) None of the above
Answer: A
461. Order by can only be used by Where Clause, correct?
a) True
b) False
Answer: B
462. What needs to be added when user want to show results by Descending Order?

a) Descending order cannot be possible.


b) User can add DESC with Order By clause
c) User can add ‘<>ASC’ with Order by Clause.
d) None of the above
Answer: B
463. What is the default order of Order by Clause?

a) Descending
b) Ascending
c) Random
d) None of the above
Answer: B
464. Among the below Order By queries, which are correct ones?

a) SELECT * FROM Table Order By Column;


b) SELECT * FROM Table Order By Column ASC;
c) SELECT * FROM Table Order By Column DESC;
d) SELECT * FROM Table Order By (n); --Where n is any column sequence number in a
table
e) All of the above
f) None of the above
Answer: E
465. Is it possible to have both Orders (i.e. ASC/DESC) in a single query?

a) True
b) False
Answer: A
466. Can ‘IN’ operator be used with Where clause?

a) True
b) False
Answer: A

467. What does UNION operator do in a SQL Server statement?

a) Bring common data from the listed tables.


b) Bring data which is not common from the listed tables.
c) Bring all data from the listed tables.
d) Bring all distinct from the listed tables.
Answer: D
468. Which one is correct syntax for applying UNION operator?

a) SELECT column_name(s) FROM table_name1 UNION table_name2


b) SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
c) UNION SELECT column_name(s) FROM table_name1
SELECT column_name(s) FROM table_name2
d) SELECT FROM table_name1 AND table_name2
Answer: B
469. How can we get all records (redundant as well as non-redundant) from union
operator?

a) Using ‘ALL’ operator with UNION.


b) Using ‘Distinct’ operator with UNION.
c) We get all records (redundant as well as non-redundant) with UNION operator by
default.
d) None of the above.
Answer: A
470. The column names in the result of a UNION (of tables) are always equal to the
column names in the 1st SELECT statement with the UNION operator, true or false?

a) True
b) False
Answer: A
471. Is UNION or UNION ALL operator valid for LONG data type column?

a) True
b) False
Answer: B
472. Can we use UNION operator in SELECT statement which contains TABLE collection
expressions?

a) True
b) False
Answer: B
473. UNION operator requires an extra overhead of removing redundant rows, is it
true?

a) True
b) False
Answer: A
474. What is true about order by with Union operator?

a) Order By can be issued in each result set.


b) It can be issued for the overall result set.
c) Both A & B.
d) None of the above
Answer: B
475. The result set will have Column names from the first query, correct?

a) True
b) False
Answer: A
476. If we know the records returned by our query are unique then which operator
will be preferred out of UNION or UNION ALL?

a) Union
b) Union ALL
Answer: B

477. The JOIN which does Cartesian Product is called?

a) Left Join
b) Left Outer Join
c) Right Outer Join
d) Cross Join
Answer: D
478. Are FULL Outer Join and Cross Join Same?

a) False
b) True
Answer: B
479. The JOIN which returns all the records from the right table in conjunction
with the matching records from the left table and if there are no matching values
in the left table, it returns NULL. Which is this JOIN?

a) Right JOIN
b) CROSS JOIN
c) LEFT Join
d) Full OUTER JOIN
Answer: A
480. What are also called Self Joins?

a) OUTER Joins
b) INNER joins
Answer: B
481. What is true about NOT INNER JOIN?

a) It is a JOIN which restricts INNER JOIN to work.


b) It is one of the type of the JOINS in SQL Server.
c) When full Outer Join is used along with WHERE. This join will give all the
results that were not present in Inner Join.
d) None of the above.
Answer: C
482. What is the other name of INNER JOIN?

a) Equi Join
b) In Join
c) Out Join
d) All of the above
Answer: A
483. List the types of Inner join?

a) Out, In, Equi


b) Left, In, Cross
c) Equi, Natural, Cross
d) None of the above
Answer: C
484. Which type of Inner Join restricts fetching of redundant data?

a) Equi.
b) Natural
c) Cross
d) Outer
Answer: B
485. Which type of Inner Join fetches result with redundant data?

a) Cross
b) Left Outer
c) IN
d) Equi
Answer: D
486. Which join is used for Joining the table to itself?

a) In
b) Natural
c) Cross
d) Self
Answer: D
487. Which join refers to join records from the right table that have no matching
key in the left table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
Answer: B

488. A __________ is a special kind of a stored procedure that executes in response


to certain action on the table like insertion, deletion or updation of data.
a) Procedures
b) Triggers
c) Functions
d) None of the mentioned
Answer: B
489 Which clause is used to filter the results of aggregate functions?
A. SELECT
B. FROM
C. WHERE
D. GROUP BY
E. HAVING
Answer: E

You might also like