Database MCQ Set 1
1. 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
Answer: b [Reason:] Triggers are automatically generated when a particular operation takes place.
2. Trigger are supported in
a) Delete
b) Update
c) Views
d) All of the mentioned
Answer
Answer: c [Reason:] The triggers run after an insert, update or delete on a table. They are not supported for views.
3. 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) None of the mentioned
Answer
Answer: b [Reason:] The triggers run after an insert, update or delete on a table. They are not supported for views.
4. 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) All of the mentioned
Answer
Answer: b [Reason:] AFTER TRIGGERS can be classified further into three types as: AFTER INSERT Trigger, AFTER UPDATE Trigger. ,AFTER DELETE Trigger.
5. The variables in the triggers are declared using
a) –
b) @
c) /
d) /@
Answer
Answer: b [Reason:] Example : declare @empid int; where empid is the variable.
6. The default extension for an Oracle SQL*Plus file is:
a) .txt
b) .pls
c) .ora
d) .sql
Answer
Answer: d [Reason:] Example :None.
7. Which of the following is NOT an Oracle-supported trigger?
a) BEFORE
b) DURING
c) AFTER
d) INSTEAD OF
Answer
Answer: b [Reason:] Example :During trigger is not possible in any database.
8. What are the different in triggers ?
a) Define, Create
b) Drop, Comment
c) Insert, Update, Delete
d) All of the mentioned
Answer
Answer: c [Reason:] Triggers are not possible for create,drop.
9. Triggers ________ enabled or disabled
a) Can be
b) Cannot be
c) Ought to be
d) Always
Answer
Answer: a [Reason:] Triggers can be manipulated.
10. Which prefixes are available to Oracle triggers?
a) : new only
b) : old only
c) Both :new and : old
d) Neither :new nor : old
Answer
Answer: c [Reason:] None.
Database MCQ Set 2
1. Which of the following creates a virtual relation for storing the query ?
a) Function
b) View
c) Procedure
d) None of the mentioned
Answer
Answer: b [Reason:] Any such relation that is not part of the logical model, but is made visible to a user as a virtual relation, is called a view.
2. Which of the following is the syntax for views where v is view name ?
a) Create view v as “query name”;
b) Create “query expression” as view;
c) Create view v as “query expression”;
d) Create view “query expression”;
Answer
Answer: c [Reason:] <query expression> is any legal query expression. The view name is represented by v.
3.
SELECT course_id FROM physics_fall_2009 WHERE building= ’Watson’;
Here the tuples are selected from the view.Which one denotes the view.
a) Course_id
b) Watson
c) Building
d) physics_fall_2009
Answer
Answer: c [Reason:] View names may appear in a query any place where a relation name may appear.
4. Materialised views make sure that
a) View definition is kept stable
b) View definition is kept up-to-date
c) View definition is verified for error
d) View is deleted after specified time
Answer
Answer: b [Reason:] None.
5. Updating the value of the view
a) Will affect the relation from which it is defined
b) Will not change the view definition
c) Will not affect the relation from which it is defined
d) Cannot determine
Answer
Answer: a [Reason:] None.
6. SQL view is said to be updatable (that is, inserts, updates or deletes can be applied on the view) if which of the following conditions are satisfied by the query defining the view?
a) The from clause has only one database relation
b) The query does not have a group by or having clause
c) The select clause contains only attribute names of the relation, and does not have any expressions, aggregates, or distinct specification
d) All of the mentioned
Answer
Answer: d [Reason:] All of the conditions must be satisfied to update the view in sql.
7. Which of the following is used at the end of the view to reject the tuples which do not satisfy the condition in where clause ?
a) With
b) Check
c) With check
d) All of the mentioned
Answer
Answer: c [Reason:] Views can be defined with a with check option clause at the end of the view definition; then, if a tuple inserted into the view does not satisfy the view’s where clause condition, the insertion is rejected by the database system.
8. Consider the two relations instructor and department
ID | Name | Dept_name | Salary |
1001 | Ted | Finance | 10000 |
1002 | Bob | Music | 20000 |
1003 | Ron | Physics | 50000 |
Department:
Dept_name | Building | Budget |
Biology | Watson | 40000 |
Chemistry | Painter | 30000 |
Music | Taylor | 50000 |
Which of the following is used to create view for these relations together?
a) CREATE VIEW instructor_info AS SELECT ID, name, building FROM instructor, department WHERE instructor.dept name= department.dept name; b) CREATE VIEW instructor_info SELECT ID, name, building FROM instructor, department; c) CREATE VIEW instructor_info AS SELECT ID, name, building FROM instructor; d) CREATE VIEW instructor_info AS SELECT ID, name, building FROM department;
Answer
Answer: a [Reason:] None.
9. For the view Create view instructor_info as
SELECT ID, name, building FROM instructor, department WHERE instructor.dept name= department.dept name;
If we insert tuple into the view as insert into instructor info values (’69987’, ’White’, ’Taylor’);
What will be the values of the other attributes in instructor and department relations?
a) Default value
b) Null
c) Error statement
d) 0
Answer
Answer: b [Reason:] The values take null if there is no constraint in the attribute else it is a Erroneous statement.
10.
CREATE VIEW faculty AS SELECT ID, name, dept name FROM instructor;
Find the error in this query .
a) Instructor
b) Select
c) View …as
d) None of the mentioned
Answer
Answer: d [Reason:] Syntax is – create view v as
Database MCQ Set 3
1. Which of the following is a valid uniform resource locator ?
a) http://www.acm.org/sigmod
b) www.google.com
c) www.ann.in
d) http:/www.acm.org/sigmod/
Answer
Answer: a [Reason:] A uniform resource locator (URL) is a globally unique name for each document that can be accessed on the Web.
2. http://www.google.com/search?q=silberschatz
In the above URL which one is the argument which is used for processing of the URL?
a) google
b) google.com
c) search
d) q=silberschatz
Answer
Answer: d [Reason:] Argument is always placed after ? symbol.
3. HTTP defines two ways in which values entered by a user at the browser can be sent to the Web server. The _____ method encodes the values as part of the URL.
a) Post
b) Get
c) Read
d) Argument
Answer
Answer: b [Reason:] For example, if the Google search page used a form with an input parameter
named q with the get method, and the user typed in the string “silberschatz” and submitted the form, the browser would request the following URL from the Web server: http://www.google.com/search?q=silberschatz.
4. A ____ is a program running on the server machine,which accepts requests from a Web browser and sends back results in the form of HTML documents.
a) HTML
b) HTTP
c) Web Server
d) Web browser
Answer
Answer: c [Reason:] The browser and Web server communicate via HTTP. Web servers provide powerful features, beyond the simple transfer of documents.
5. The application program typically communicates with a database server, through _____ or other protocols, in order to get or store data.
a) JDBC
b) ODBC
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] The common gateway interface (CGI) standard defines how the Web server communicates with application programs.
6. This extra information is usually maintained in the form of a ___ at the client.
a) Cookie
b) History
c) Remainder
d) None of the mentioned
Answer
Answer: a [Reason:] A cookie is simply a small piece of text containing identifying information and with an associated name.
7. Which of the following is not true about HTML ?
a) <meta>…</meta>
b) <meta…./>
c) <metadata>…</metadata>
d) <metadata name=”” />
Answer
Answer: b [Reason:] Meta data is the data about data which is included in the meta data tag.
8. Html code contains:
a) Tags
b) Attributes
c) Elements
d) All of the mentioned
Answer
Answer: d [Reason:] <> are tags,size is a attribute.
9. Html document must always be saved with:
a) .html
b) .htm
c) .doc
d) Both .html & .htm
Answer
Answer: d [Reason:] .doc is used only for the word document format.
10. How many levels of headings are in html:
a) 2
b) 7
c) 6
d) 4
Answer
Answer: c [Reason:] The heading levels are h1,h2,h3,h4,h5,h6.
Database MCQ Set 4
1._____ feature will be removed in a future version of Microsoft SQL Server.
a) Log shipping
b) Database snapshots
c) Database mirroring
d) None of the mentioned
Answer
Answer: c [Reason:] Use AlwaysOn Availability Groups instead of database mirroring.
2. Point out the correct statement :
a) Database mirroring is a solution for lowering the availability of a SQL Server database
b) Log shipping is a solution for increasing the availability of a SQL Server database
c) Mirroring is implemented on a per-database basis
d) All of the mentioned
Answer
Answer:c [Reason:] Mirroring works only with databases that use the full recovery model.
3. Which of the following benefit is provided by database mirroring ?
a) Increases data protection
b) Improves the availability of the production database
c) Increases availability of a database
d) All of the mentioned
Answer
Answer: d [Reason:] To minimize downtime for a mirrored database, you can sequentially upgrade the instances of SQL Server that are hosting the failover partners.
4. Database mirroring operates in how many modes ?
a) 2
b) 3
c) 4
d) 5
Answer
Answer: b [Reason:] Database mirroring operates in three different modes: high-availability mode, high-protection mode, and high-performance mode.
5. Point out the wrong statement :
a) Mirror database is the copy of the database that is typically fully synchronized with the principal database
b) Redo queue is received transaction log records that are waiting on the disk of a mirror server
c) Database mirroring provides less redundancy of the data
d) All of the mentioned
Answer
Answer: c [Reason:] Database mirroring provides complete or almost complete redundancy of the data depending on whether the operating mode is high-safety or high-performance.
6. Which of the following modes writes the data on the principal and mirror databases synchronously ?
a) High safety with automatic cluster
b) High safety
c) High safety with automatic failover
d) High performance
Answer
Answer: a [Reason:] In high safety with automatic cluster,Data is written and must be committed synchronously both on the principal and mirror databases.
7.The high performance mode is only available in the ____ edition of SQL Server.
a) Enterprise
b) Express
c) Compact
d) None of the mentioned
Answer
Answer: a [Reason:] In high performance mode, the asynchronous communication, data is written and committed on the principal server, and later sent and committed to the mirror server.
8. Which of the following script will backup the database requires for database mirroring ?
a)
USE master GO Backup DATABASE DB1 TO disk ='C:BackupsDB1.Bak' WITH initialize GO Backup log DB1 TO disk ='C:BackupsDB1.trn' WITH initialize GO
b)
USE master GO Backup DATABASE DB1 TO disk ='C:BackupsDB1.Bak' WITH init GO Backup log DB1 TO disk ='C:BackupsDB1.trn' WITH init GO
c)
USE master GO Back DATABASE DB1 TO disk ='C:BackupsDB1.Bak' WITH init GO Back log DB1 TO disk ='C:BackupsDB1.trn' WITH init GO
d) All of the mentioned
Answer
Answer: b [Reason:] You have to backup the database and transaction on the principal server for database mirroring.
9. Which of the following is upgrade step to database mirroring ?
a) Switch to high performance (sync)
b) Perform a rolling upgrade
c) Switch back to high performance (sync)
d) None of the mentioned
Answer
Answer: b [Reason:] Upgrade mirror, manual failover to mirror, upgrade original principal, manual failover to original principal.
10. Which of the following pair of technology is supported in SQL Server ?
a) Mirroring and Replication
b) Mirroring and Clustering
c) Mirroring and Log Shipping
d) All of the mentioned
Answer
Answer: d [Reason:] Database mirroring is a solution for increasing the availability of a SQL Server database. Mirroring is implemented on a per-database basis and works only with databases that use the full recovery model.
Database MCQ Set 5
1. Insert the appropriate key word in the blank in the query ( A is a relation)
delete ______ A
where P < 5;
a) all
b) from
c) with
d) in
Answer
Answer: a [Reason:] the from key word is specified beside delete clause to indicate the relation from which the tuple needs to be deleted.
2. How many relations can a delete command operate on?
a) 0
b) 1
c) 2
d) Infinitely many
Answer
Answer: b [Reason:] The delete command can operate only on one relation. You cannot give commands like delete R1, R2.
3. What is the result of the following query?
DELETE FROM student WHERE marks < (SELECT avg(marks) FROM student);
a) The query deletes all the tuples whose marks are greater than the average marks
b) The query deletes all the tuples whose marks are less than the average marks
c) The query deletes all the values under the marks attribute which are less than the average
d) The query is syntactically wrong and does not execute
Answer
Answer: b [Reason:] The query deletes all the tuples from the student relation as per the condition specified in the where clause i.e. wherever the marks are less than average marks.
4. What is the format of entering date into a database while inserting data into it?
a) YYYY-MM-DD
b) “YYYY-MM-DD”
c) ‘YYYY-MM-DD’
d) “DD-MM-YYYY”
Answer
Answer: c [Reason:] The correct format for entering date into the database while inserting data is
‘YYYY-MM-DD’.
5. Choose the correct option regarding the following query
INSERT INTO course ('CS-67' , 'course name', 'any' , 5);
a) Data is inserted into the course relation
b) Data is not inserted into the course relation due to incorrect specification
c) Data is inserted into the CS-67 relation
d) Data is not inserted due to the incorrect use of syntax
Answer
Answer: d [Reason:] Data is not inserted because, the proper syntax is
insert into <relation name> values (<data>);
6. To change a value in a tuple without changing all the values in the tuple, we use the _____ statement
a) insert
b) insert some
c) update
d) alter
Answer
Answer: c [Reason:] To change a value in a tuple without changing the entire values in the tuple, we use the update statement. Eg: update employee set salary = salary*1.5;
7. What does the following query do?
UPDATE student SET marks = marks*1.10;
a) It increases the marks of all the students by 10%
b) It decreases the marks of all the students by 90%
c) It increases the marks of all the students by 110%
d) It is syntactically wrong
Answer
Answer: a [Reason:] The update clause is used to edit a specific value in the tuple. The set command is used to set the value of an attribute in a tuple.
8. State true or false: We cannot write a where clause under an update command
a) True
b) False
Answer
Answer: b [Reason:] Writing a where clause under the update statement enables us to specify a condition for the selection of tuples whose values need to be updated.
9. Scalar Subqueries can be used in the SQL update statement when they are used under the ____ clause
a) where
b) with
c) set
d) end
Answer
Answer: c [Reason:] SQL subqueries that can occur wherever a value is permitted provided the subquery gives only one tuple with a single attribute are called Scalar subqueries. Scalar Subqueries can be used in the SQL update statement when they are used under the set clause.
10. Which of the following cannot be used to modify the data in a database
a) update
b) insert
c) delete
d) drop
Answer
Answer: d [Reason:] The drop keyword is used to delete the entire relation leaving no trace of it in the memory. Thus it cannot be used to edit the data in the relation.