RDBMS Objective Type Questions with Answers


Hello friends in this article we are going to discuss about RDBMS Multiple Choice Questions with answer | RDBMS Objective Type Questions with Answers | RDBMS Quiz with answer | RDBMS Interview Questions with answers | RDBMS Online Quiz for practise

61.Choose an SQL query to find name of all the employees whose name contain the word
“kumar” example kumaran, arun kumar (kumar will be at any place)

Ans-
SELECT * FROM employees where lower(name) like “%kumar%”;

62.Given two executable queries
a.) select name, address from users where user_id not in(select user_id from bookingdetails where
lower(name)=’city union bank’) order by name;
b.) select name, address from users where user_id in (select user_id from bookingdetails where
lower(name) != “city union bank”) order by name;
will both queries produce the same output?

Ans- True

63.which of the following statements are true with respect to “a query with join operation”?

ANS – You must refer to the columns that are common to 2 tab…
You must have the column common to 2 tables in the….

64.Which of the following statements is true with respect to given Oracle query
Start program
Create table AQI_DELHI_1 as Select * from AQI_DELHI;

Ans-
Table “AQI_DELHI_1” is created with same structure as that of “AQI_DELHI” table – with
AQI_DELHI table’s data

65.Customer(customerId,customerName) – customerId is primary key
Account(accountId,accountType,balance,customerId) – accountId is primary key and customerId is foreign key Which is the CORRECT SQL statement to retrieve customerId, customerName, accountId and balance for all customers. It
should also display the details of the customers who are not having any account.

ANS – SELECT c.customerId,c.customerNam
e,a.accountId,a.balance
FROM account a RIGHT OUTER JOIN
customer c
ON c.customerId=a.customerId;

66.Consider the following tables:
Account(AccountNumber, AccountOpeningDate, Balance). Here AccountNumber is
the primary key.
Transaction(TransactionId, AccountNumber, DateOfTransaction, Amount, TransactionType);
Here TransactionId is the primary key and AccountNumber is the foreign key
referencing AccountNumber in Account table.Which is the CORRECT query to display AccountNumber and balance of accounts on which NO transaction was done after ’31-
Dec-2015′;

ANS – SELECT AccountNumber,Balance
FROM Account
WHERE AccountNumber NOT IN
(SELECT AccountNumber FROM
Transaction
WHERE DateOfTransaction > ’31-Dec-
2015′);

67.Consider the table Project(projectId, projectType,budget).
Which is the CORRECT SQL statement to retrieve the projectType(s) which has more than 10 projects?

ANS – SELECT projectType FROM project
GROUP BY projectType
HAVING COUNT(projectId)>10;

68.Consider table Employee(EmployeeId, EmployeeName,DeptCode) .
Which is the CORRECT SQL query to display the EmployeeId and EmployeeName of employees who are working in DeptCode
10 OR 20?

(i) SELECT EmployeeId,EmployeeName FROM Employee WHERE DeptCode IN (10,20);
(ii) SELECT EmployeeId,EmployeeName FROM Employee WHERE DeptCode = 10 OR DeptCode = 20;

ANS – Both (i) and (ii)

69.Publisher(PublisherCode, PublisherName, Address, Email). Here PublisherCode is the primary key;
Book (ISBN, Title, Author, Price, PublisherCode). Here ISBN is the Primary Key and PublisherCode is the foreign key
referencing the PublisherCode in Publisher table.
Which is the CORRECT SQL query to display ISBN, Title, Author, PublisherCode and PublisherName for all the books.

ANS – SELECT Book.ISBN, Book.Title,
Book.Author, Book.PublisherCode,
Publisher.PublisherName
FROM Book INNER JOIN Publisher
ON Book.PublisherCode =
Publisher.PublisherCode;

70.Refer the code given below:
Employee emp = new Employee();
Employee emp1 = new Employee();
Employee emp2 = emp;
Employee emp3;
emp=null;
emp3=emp;
//Line1
Assume that class Employee is a valid Java class.
How many objects are eligible for garbage collection at Line1?

ANS – 1

71.Assume that Table Customer is created in database using the create statement given below.
CREATE TABLE Customer(
CustomerId NUMBER(5) CONSTRAINT cust_pk PRIMARY KEY,
CustomerName VARCHAR2(20) CONSTRAINT cust_nn NOT NULL);
Choose the appropriate ALTER statement to drop primary key constraint of table Customer.

ANS – ALTER TABLE Customer DROP
CONSTRAINT cust_pk

72.Consider table Project(projectId, projectType, budget).
Which is the CORRECT SQL statement to display projectId, projectType and budget of project which is having minimum budget
in each project type?

ANS – SELECT p1.projectId,
p1.projectType,p1.budget FROM
project p1
WHERE p1.budget IN(
SELECT MIN(p2.budget) FROM
project p2
WHERE
p1.projectType=p2.projectType);

73.Consider the below tables.Actor(actorId,actorName) – actorId is primary key
Event(eventId,eventName) – eventId is primary key
Registration(registrationId,actorId,eventId) – actorId and eventId are foreign keys

Which is the CORRECT SQL statement to retrieve actorId, actorName and eventId for all actors who has registered for an
event. If any actor is not registered for any event, still the actor details should be displayed.

ANS – SELECT
a.actorId,a.actorName,r.eventId
FROM Actor a LEFT OUTER JOIN
Registration r
ON a.actorid=r.actorid;

74.Consider the table Student(StudentId, StudentName, Email, PercentageOfMarks).
Which is the CORRECT query to display the details in the decreasing order (highest to lowest) of PercentageOfMarks and in
the alphabetical order (A-Z) of StudentName in case PercentageOfMarks is the same

ANS – SELECT StudentId, StudentName,
Email, PercentageOfmarks
FROM Student ORDER BY
PercentageOfMarks DESC,
StudentName;

75.How many row(s) will be deleted after executing the SQL statement given below?
DELETE FROM Player WHERE Salary>=20000 AND PlayerAverage<70;

ANS – 0


76.Consider table Account(customerid, accountid, accounttype,balance) has been created with customerid as primary key.
Identify ALTER statement which executes successfully on account table. [Note: Table has no records]

ANS – ALTER TABLE Account ADD
CONSTRAINT acc_chek
CHECK(accounttype IN(‘C’,’S’));

77.Publisher(PublisherCode, PublisherName, Address, Email). Here PublisherCode is the primary key;
Book (ISBN, Title, Author, Price, PublisherCode). Here ISBN is the Primary Key and PublisherCode is the foreign key
referencing the PublisherCode in Publisher table.
Which is the CORRECT SQL query to display ISBN, Title, Author, PublisherCode and PublisherName for all the books.

ANS – SELECT Book.ISBN, Book.Title,
Book.Author, Book.PublisherCode,
Publisher.PublisherName
FROM Book INNER JOIN Publisher
ON Book.PublisherCode =
Publisher.PublisherCode;

78.The following statement is True/False?
Is it mandatory for foreign key column to have the same data type of primary key in case of writing the querry of join to fetch
data from multiple tables.

ANS – True

79.Which is the CORRECT SQL statement to add the new column “DateOfJoining” to an existing table “Employee”?

a. CREATE TABLE Employee ADD DateOfJoining DATE;
b. ALTER TABLE Employee MODIFY DateOfJoining DATE;
c. ALTER TABLE Employee UPDATE DateOfJoining DATE;
d. ALTER TABLE Employee ADD DateOfJoining DATE;

Ans: D

80.Which of the following statement(s) is/are TRUE?
(i) In a non-correlated(independent) subquery, the subquery is always executed only once.
(ii) In a non-correlated(independent) subquery, the inner query (sub query) references the column from the outer query (main
query).

a. Neither (i) nor (ii)
b. Only (ii)
c. Both (i) and (ii)
d. Only (i)

Ans: D

81.Which of the following is CORRECT about DELETE command?
a) It can delete single or multiple columns from a table
b) It can delete single or multiple records from a table
c) Records deleted can be roll backed.
Choose most appropriate option.

ANS – b and c

82.What is the SQL query for finding the total number of rows in a given table ’emp’? Choose most appropriate option.

ANS – SELECT COUNT(*) FROM EMP;

83.Which of the following SQL commands is used to remove table “EMPLOYEE” present in the database?

ANS – DROP TABLE EMPLOYEE;

84.Which of the following about DELETE command in SQL is FALSE?

ANS – Used for deleting a single column value in a record

85.Given a table Projects, which of the following SQL queries will display records that contains Sub-String “SAP” any where in the
ProjectName ?

a. SELECT * FROM Projects WHERE ProjectName LIKE “%SAP%”;
b. SELECT * FROM Projects WHERE ProjectName = ‘%SAP%’;
c. SELECT * FROM Projects WHERE ProjectName LIKE ‘%SAP’;

Ans: A

86.A not null column cannot be created at table level during table creation. State
true/false.

Ans: False

87.if you create a view WITH READ ONLY option,it can only be viewed and not
updated. State true/false

Ans: True

« Previous


Leave a Reply

Your email address will not be published. Required fields are marked *