SQL Answer Set-1 - Basasql
SQL Answer Set-1 - Basasql
basasql
6) With SQL, how do you select a column named “FirstName” from a table named “Persons”?
b) SELECT FirstName FROM Persons
7) With SQL, how do you select all the columns from a table named “Persons”?
d) SELECT * FROM Persons
8) With SQL, how do you select all the records from a table named “Persons” where the value of the
column “FirstName” is “Peter”?
eter’
d)SELECT * FROM Persons WHERE FirstName=’Peter’
9) With SQL, how do you select all the records from a table named “Persons” where the value of the
column “FirstName” starts with an “a”?
d) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
10) The OR operator displays a record if ANY conditions listed are true. The AND operator displays a
record if ALL of the conditions listed are true
a) True
11) With SQL, how do you select all the records from a table named “Persons” where the “FirstName” is
“Peter” and the “LastName” is “Jackson”?
b) SELECT * FROM Persons WHERE FirstName=’Peter’ AND LastName=’Jackson’
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 1/21
5/25/2019 SQL Answer Set-1 – basasql
12) With SQL, how do you select all the records from a table named “Persons” where the “LastName” is
alphabetically between (and including) “Hansen” and “Pe ersen”?
b) SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pe ersen’
15) With SQL, how can you return all the records from a table named “Persons” sorted descending by
“FirstName”?
b) SELECT * FROM Persons ORDER BY FirstName DESC
16) With SQL, how can you insert a new record into the “Persons” table?
a) INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)
17) With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?
a) INSERT INTO Persons (LastName) VALUES (‘Olsen’)
18) How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?
b) UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’
19) With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?
a) DELETE FROM Persons WHERE FirstName = ‘Peter’
20) With SQL, how can you return the number of records in the “Persons” table?
b) SELECT COUNT(*) FROM Persons
21) Given an employees table as follows: empid name managerid a1 bob NULL b1 jim a1 B2 tom a1
What value will select count(*) from employees return?
c) 3
23) Sometimes the expression “select count(*)” will return fewer rows than the expression “select
count(value)”.
b) False
24) What type of lock will deny users any access to a table?
c) EXCLUSIVE
25) Which of the following is the correct SQL statement to use to remove rows from a table?
c) DELETE
26) The only way to join two tables is by using standard, ANSI syntax.
b) False
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 2/21
5/25/2019 SQL Answer Set-1 – basasql
28) The left outer join is one type of outer join. Another one is the.
e)all of the above
Question 1
Examine the two SQL statements given below:
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
The second statement returns an error
Question 2
Which of the following is not a numeric group function?
Highest
Question 3
Examine the data in the EMPLOYEES table given below:
ALLEN 10 3000
MILLER 20 1500
KING 20 2200
DAVIS 30 5000
Which of the following Subqueries work?
SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM
employees GROUP BY department_id);
SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM
employees GROUP BY department_id);
Question 4
Which of the following statements are true?
With DDL you can create and remove tables, schemas, domains, indexes and views
Question 5
Which of the following clauses are not allowed in a single row sub-query?
Order by
Question 6
What is the collection of information stored in a database at a particular moment called?
Instance
Question 7
The overall logical structure of a database can be expressed graphically by:
Entity-Relationship Diagram
Question 8
Consider the following tables:
Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 3/21
5/25/2019 SQL Answer Set-1 – basasql
Question 9
Which statements are true for views?
The definition of a view is stored in data dictionary
Views provide a more secure way of retrieving data
Question 10
Consider the following tables:
Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
———
SubjectId
Subject (such AS History, Geography, Mathematics etc
Authors
——–
AuthorId
AuthorName
Country
What is the query to determine which Authors have wri en books on two or more subjects?
select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId
having count(*)>1)
Question 11
What does the term DDL stand for?
Data Definition Language
Question 12
The concept of data independence is similar to the concept of ________
Abstract data type
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 4/21
5/25/2019 SQL Answer Set-1 – basasql
Question 13
What are the programs that execute automatically whenever DML operations are performed on tables
called?
Triggers
Question 14
What clause should be used to display the rows of a table in ascending order of a particular column?
Order By
Question 15
What is the error in the following query if the Students table contains several records?
SELECT name FROM students WHERE name =
(SELECT name FROM students ORDER BY name);
= should be replace by in operator
An order by clause is not allowed in a subquery
Question 16
How can data be accessed by users who do not have direct access to the tables?
By creating views
Question 17
Consider the following tables:
Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
———
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
——–
AuthorId
AuthorName
Country
What is the query to determine which Authors have wri en at least 1 book with a popularity rating of
less than 5?
select authorname from authors where authorid in (select authorid from books where
popularityrating<5) Question 18 An RDBMS performs the following steps: 1)It calculates the results of
the group functions of each group 2)It groups those rows together based on the group by clause 3)It
orders the groups based on the results of the group functions in the order by clause 4)It chooses and
eliminates groups based on the having clause 5)It chooses rows based on the where clause Arrange the
above steps in the correct order of execution: 5,2,1,4,3 Question 19 _________ is the operation that
displays certain columns from the table. Selection Question 20 There is a column c1 in the table t to
which a primary key pk is to be added. What will be the correct syntax? Alter table t add primary
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 5/21
5/25/2019 SQL Answer Set-1 – basasql
key(c1); Question 21 Which of the following are aggregate functions in SQL? Avg Sum Question 22 A
table Students has a column called name which stores the names of the students. What will be the correct
query to display the names of the students in reverse order? Select name from students order by name
desc; Question 23 The primary key index does not allow ________ data in a field. Null Duplicate1) What
does SQL stand for? c) Structured Query Language 2) Which SQL statement is used to extract data from
a database? d) SELECT 3) Which SQL statement is used to update data in a database? a) UPDATE 4)
Which SQL statement is used to delete data from a database? b) DELETE 5) Which SQL statement is
used to insert new data in a database? c) INSERT 6) With SQL, how do you select a column named
“FirstName” from a table named “Persons”? b) SELECT FirstName FROM Persons 7) With SQL, how do
you select all the columns from a table named “Persons”? d) SELECT * FROM Persons 8) With SQL,
how do you select all the records from a table named “Persons” where the value of the column
“FirstName” is “Peter”? eter’ d)SELECT * FROM Persons WHERE FirstName=’Peter’ 9) With SQL, how
do you select all the records from a table named “Persons” where the value of the column “FirstName”
starts with an “a”? d) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’ 10) The OR operator
displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the
conditions listed are true a) True 11) With SQL, how do you select all the records from a table named
“Persons” where the “FirstName” is “Peter” and the “LastName” is “Jackson”? b) SELECT * FROM
Persons WHERE FirstName=’Peter’ AND LastName=’Jackson’ 12) With SQL, how do you select all the
records from a table named “Persons” where the “LastName” is alphabetically between (and including)
“Hansen” and “Pe ersen”? b) SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND
‘Pe ersen’ 13) Which SQL statement is used to return only different values? d) SELECT DISTINCT 14)
Which SQL keyword is used to sort the result-set? c) ORDER BY 15) With SQL, how can you return all
the records from a table named “Persons” sorted descending by “FirstName”? b) SELECT * FROM
Persons ORDER BY FirstName DESC 16) With SQL, how can you insert a new record into the “Persons”
table? a) INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’) 17) With SQL, how can you insert “Olsen”
as the “LastName” in the “Persons” table? a) INSERT INTO Persons (LastName) VALUES (‘Olsen’) 18)
How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table? b)
UPDATE Persons SET LastName=’Nilsen’ WHERE LastName=’Hansen’ 19) With SQL, how can you
delete the records where the “FirstName” is “Peter” in the Persons Table? a) DELETE FROM Persons
WHERE FirstName = ‘Peter’ 20) With SQL, how can you return the number of records in the “Persons”
table? b) SELECT COUNT(*) FROM Persons 21) Given an employees table as follows: empid name
managerid a1 bob NULL b1 jim a1 B2 tom a1 What value will select count(*) from employees return? c) 3
22) The result of a SELECT statement can contain duplicate rows. a) True 23) Sometimes the expression
“select count(*)” will return fewer rows than the expression “select count(value)”. b) False 24) What type
of lock will deny users any access to a table? c) EXCLUSIVE 25) Which of the following is the correct
SQL statement to use to remove rows from a table? c) DELETE 26) The only way to join two tables is by
using standard, ANSI syntax. b) False 27) A NULL value is treated as a blank or 0. b) False 28) The left
outer join is one type of outer join. Another one is the. e)all of the above Question 1 Examine the two
SQL statements given below: SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY
salary DESC SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC The second
statement returns an error Question 2 Which of the following is not a numeric group function? Highest
Question 3 Examine the data in the EMPLOYEES table given below: ALLEN 10 3000
MILLER 20 1500 KING 20 2200 DAVIS 30
5000 Which of the following Subqueries work? SELECT distinct department_id FROM employees Where
salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM
employees GROUP BY department_id);
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 6/21
5/25/2019 SQL Answer Set-1 – basasql
Question 4
Which of the following statements are true?
With DDL you can create and remove tables, schemas, domains, indexes and views
Question 5
Which of the following clauses are not allowed in a single row sub-query?
Order by
Question 6
What is the collection of information stored in a database at a particular moment called?
Instance
Question 7
The overall logical structure of a database can be expressed graphically by:
Entity-Relationship Diagram
Question 8
Consider the following tables:
Books
——
BookId
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
———
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
——–
AuthorId
AuthorName
Country
What is the query to determine which German books(if any) are more popular than all the French?
select bookname from books where language=’German’ and popularityrating> (select
max(popularityrating) from books where language=’French’)
Question 9
Which statements are true for views?
The definition of a view is stored in data dictionary
Views provide a more secure way of retrieving data
Question 10
Consider the following tables:
Books
——
BookId
BookName
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 7/21
5/25/2019 SQL Answer Set-1 – basasql
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
———
SubjectId
Subject (such AS History, Geography, Mathematics etc
Authors
——–
AuthorId
AuthorName
Country
What is the query to determine which Authors have wri en books on two or more subjects?
select AuthorName from Authors where Authorid in (select Authorid from Books group by SubjectId
having count(*)>1)
Question 11
What does the term DDL stand for?
Data Definition Language
Question 12
The concept of data independence is similar to the concept of ________
Abstract data type
Question 13
What are the programs that execute automatically whenever DML operations are performed on tables
called?
Triggers
Question 14
What clause should be used to display the rows of a table in ascending order of a particular column?
Order By
Question 15
What is the error in the following query if the Students table contains several records?
SELECT name FROM students WHERE name =
(SELECT name FROM students ORDER BY name);
= should be replace by in operator
An order by clause is not allowed in a subquery
Question 16
How can data be accessed by users who do not have direct access to the tables?
By creating views
Question 17
Consider the following tables:
Books
——
BookId
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 8/21
5/25/2019 SQL Answer Set-1 – basasql
BookName
AuthorId
SubjectId
PopularityRating (the popularity of the book ON a scale of 1 TO 10)
Languag? (such AS French, English, German etc)
Subjects
———
SubjectId
Subject (such AS History, Geography, Mathematics etc)
Authors
——–
AuthorId
AuthorName
Country
What is the query to determine which Authors have wri en at least 1 book with a popularity rating of
less than 5?
select authorname from authors where authorid in (select authorid from books where
popularityrating<5)
Question 18
An RDBMS performs the following steps:
1)It calculates the results of the group functions of each group
2)It groups those rows together based on the group by clause
3)It orders the groups based on the results of the group functions in the order by clause
4)It chooses and eliminates groups based on the having clause
5)It chooses rows based on the where clause
Arrange the above steps in the correct order of execution:
5,2,1,4,3
Question 19
_________ is the operation that displays certain columns from the table.
Selection
Question 20
There is a column c1 in the table t to which a primary key pk is to be added. What will be the correct
syntax?
Alter table t add primary key(c1);
Question 21
Which of the following are aggregate functions in SQL?
Avg
Sum
Question 22
A table Students has a column called name which stores the names of the students. What will be the
correct query to display the names of the students in reverse order?
Select name from students order by name desc;
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 9/21
5/25/2019 SQL Answer Set-1 – basasql
Question 23
The primary key index does not allow ________ data in a field.
Null
Duplicate
Answer: a
Explanation: Triggers are used to assess/evaluate data before or after data modification using DDL and
DML statements.
Answer: a
Explanation:Triggers are special type of stored procedure that automatically execute when a DDL or
DML statement associated with the trigger is executed.
Answer: a
Explanation:In Sql Server we can create four types of triggers Data Definition Language (DDL) triggers,
Data Manipulation Language (DML) triggers, CLR triggers and Logon triggers.
Answer: d
Explanation:We have two types of DML triggers-AFTER and INSTEAD OF.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 10/21
5/25/2019 SQL Answer Set-1 – basasql
Answer:d
Explanation:INSTEAD OF triggers cause their source DML operation to skip and they just execute the
code provided inside them.
Answer: c
Explanation:AFTER trigger fires after SQL Server completes the execution of the action successfully that
fired it.
Answer: d
Explanation:In SQL Server we can create triggers on DML statements (like INSERT, UPDATE, and
DELETE) and stored procedures that perform DML-like operations.
Answer: a
Explanation:AFTER triggers do not work for views.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 11/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: b
Explanation:Valid trigger actions are INSERT, UPDATE and DELETE, or a combination of several,
separated by commas.
Answer: a
Explanation:You can also use the ALL keyword instead of a trigger name to enable/disable all of the
triggers on a table in question.
Answer: d
Explanation:CLR integration of triggers has been introduced with SQL Server 2008 and allows for
triggers to be coded in one of .NET languages like C#, Visual Basic and F#.
Answer: a
Explanation:Logon event is raised when a user session is being established with Sql Server that is made
after the authentication phase finishes.
Answer: a
Explanation:In SQL Server we can create triggers on DDL statements (like CREATE, ALTER, and DROP).
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 12/21
5/25/2019 SQL Answer Set-1 – basasql
c) LOGON
d) CLR
View Answer
Answer: b
Explanation:We can use only FOR/AFTER clause in DDL triggers not INSTEAD OF clause means we can
make only After Trigger on DDL statements.
Answer: b
Explanation:DDL triggers are a special kind of trigger that fire in response to Data Definition Language
(DDL) statements.
Answer: d
Explanation:DDL triggers fire in response to a variety of Data Definition Language (DDL) events.
7. DDL triggers can only fire after the ______ statement has occurred.
a) DML
b) CLR
c) DDL
d) All of the mentioned
View Answer
Answer: c
Explanation:DDL Triggers can be set with either a Server scope or database scope.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 13/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: b
Explanation:Transact-SQL DDL Trigger and CLR DDL Trigger are two types of DDL Trigger.
9. ____________ triggers do not create the special inserted and deleted tables.
a) DML
b) CLR
c) DDL
d) All of the mentioned
View Answer
Answer: c
Explanation:DDL triggers do not fire in response to events that affect local or global temporary tables
and stored procedures.
Answer: a
Explanation:DDL triggers can be server-scoped or database-scoped. A database-scoped DDL trigger is
simply called a database trigger.
Answer: a
Explanation:There are mainly two ways to audit:Using backups and Scripts in SQL Server.
Answer: a
Explanation:Whether you do or not, this code in source control will need to be stored separately from
your development code in order to isolate keeping track of production changes from your development
processor.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 14/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: d
Explanation:All audits are disabled when initially created.
Answer: b
Explanation:BACKUP_RESTORE_GROUP event is raised whenever a backup or restore command is
issued.
Answer: c
Explanation:AUDIT_ CHANGE_GROUP event is raised whenever CREATE SERVER AUDIT is issued.
Answer: d
Explanation:Any change to an audit is audited in that audit.Equivalent to the Audit Change Audit Event
Class.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 15/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: a
Explanation:DATABASE_OBJECT_ACCESS_GROUP event is raised for any access to any database.
8. You can use the handy event name of __________ to make sure your trigger covers all DDL events.
a) DDL_DATABASE_EVENTS
b) DDL_DATABASE_LEVEL_EVENTS
c) DDL_DATABASE_LEVEL
d) All of the mentioned
View Answer
Answer: b
Explanation:DDL_DATABASE_LEVEL_EVENTS is used for auding database objects in SQL Server.
9. DDL Trigger can capture the information about the EVENT that fired it by using __________
function.
a) EVENTDATA()
b) EVENT()
c) EVENTS()
d) None of the mentioned
View Answer
Answer: a
Explanation:The EventData xml value includes the triggering SQL statement, the event time, the type of
event and depending on what type of event was called, extra information such as the database name.
10. Which of the following database level event si raised whenever a REFERENCESpermission is
checked. ?
a) EXECUTE
b) REFERENCES
c) UPDATE
d) SELECT
View Answer
Answer: b
Explanation:Database-level audit actions do not apply to Columns.
Answer: a
Explanation:Northwind is a sample database.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 16/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: a
Explanation:Tempdb holds all temporary tables and temporary stored procedures.
Answer: b
Explanation:The master database records all of the system level information for a SQL Server system.
Answer: b
Explanation: Master is the database that records the existence of all other databases.
Answer: d
Explanation:When a CREATE DATABASE statement is issued, the first part of the database is created by
copying in the contents of the modeldatabase.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 17/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: b
Explanation:The msdb database is used by SQL Server Agent for scheduling alerts and jobs, and
recording operators.
8. How many types of system databases are present in SQL Server 2008?
a) 3
b) 4
c) 5
d) 6
View Answer
Answer: b
Explanation:Microsoft SQL Server 2008 have four system databases.
9. Which of the following system database occupies more space and memory ?
a) Master
b) Msdb
c) Tempdb
d) Model
View Answer
Answer: a
Explanation:The master database records all of the system level information for a SQL Server system.
10. The _________ database stores basic configuration information for the server.
a) Master
b) Msdb
c) Tempdb
d) Model
View Answer
Answer: a
Explanation:Master database includes information about the file locations of the user databases, as well
as logon accounts, server configuration se ings, and a number of other items such as linked servers and
startup stored procedures.
1. . __________ is a Microsoft Windows service that executes scheduled administrative tasks, which are
called jobs in SQL Server 2014.
a) Log shipping
b) Task
c)Agent
d) None of the mentioned
View Answer
Answer: c
Explanation:The SQL Server Agent is a service that lets you configure scheduled tasks and system alerts.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 18/21
5/25/2019 SQL Answer Set-1 – basasql
c) By default, the SQL Server Agent service is disabled when SQL Server 2014 is installed
d) All of the mentioned
View Answer
Answer: d
Explanation:SQL Server Agent runs continuously in the background as a Windows Service.
Answer: a
Explanation:msdb is a system database that is created when you first install SQL Server.
Answer: c
Explanation:SQL Server Agent is used to create and schedule a job that automates database
administration.
Answer: d
Explanation:Open up Microsoft SQL Server Configuration Manager and locate the SQL
Server Agent service. If the status of that service is “RUNNING”, you do not need to do anything.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 19/21
5/25/2019 SQL Answer Set-1 – basasql
Answer: d
Explanation:A schedule specifies when a job runs.
Answer: c
Explanation:An alert is an automatic response to a specific event. For example, an event can be a job that
starts or system resources that reach a specific threshold.
Answer: d
Explanation:An operator defines contact information for an individual responsible for the maintenance
of one or more instances of SQL Server.
Answer: b
Explanation:Members of the SQLAgentUserRole, SQLAgentReaderRole, and SQLAgentOperatorRole
fixed database roles in msdb, and members of the sysadmin fixed server role have access to SQL
Server Agent
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 20/21
5/25/2019 SQL Answer Set-1 – basasql
Advertisements
REPORT THIS AD
CREATE A FREE WEBSITE OR BLOG AT WORDPRESS.COM.
https://basasql.wordpress.com/2015/06/14/sql-answer-set-1/ 21/21