gfg dbms interview question1
gfg dbms interview question1
Aptitude Engineering Mathematics Discrete Mathematics Operating System DBMS Computer Networks
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 1/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
6. What are the differences between DDL, DML, and DCL in SQL?
Following are some details of three :
DDL stands for Data Definition Language. SQL queries like CREATE, ALTER,
DROP, TRUNCATE and RENAME come under this.
DML stands for Data Manipulation Language. SQL queries like SELECT,
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 2/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
9. What is Join?
An SQL Join is used to combine data from two or more tables, based on a
common field between them. For example, consider the following two
tables.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 3/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
CourseID EnrollNo
1 1000
2 1000
3 1000
1 1002
2 1003
CourseID StudentName
1 geek1
1 geek3
2 geek1
3 geek1
9. What is Identity?
Identity (or AutoNumber) is a column that automatically generates numeric
values. A start and increment value can be set, but most DBA leave these at
1. A GUID column also generates numbers; the value of this cannot be
controlled. Identity/GUID columns do not need to be indexed.
A clause in SQL is a part of a query that lets you filter or customize how you
want your data to be queried to you.
Purpose of normalization:
It is helpful to divide the large database table into smaller tables and link
them using relationships.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 7/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
Example: There are 2 tables – Employee and Department. Both have one
common field/column as ‘ID’ where ID is the primary key of
the Employee table while this is the foreign key for the Department table.
27.What are the main differences between Primary key and Unique Key?
The main difference between the Primary key and the Unique key is that the
Primary key can never have a null value while the Unique key may consist of
a null value.
In each table, there can be only one primary key while there can be more
than one unique key in a table.
Sub-query is basically the query that is included inside some other query
and can also be called an inner query which is found inside the outer query.
29. What is the use of the DROP command and what are the differences
between DROP, TRUNCATE and DELETE commands?
DROP and TRUNCATE commands are the DDL commands which are used to
delete tables from the database.
And when we make use of a DROP command, the tables get deleted
permanently all the privileges and indexes that are related to the table also
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 8/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
get deleted. This operation cannot be rolled back and so should be used
only when necessary.
30. What is the main difference between UNION and UNION ALL?
UNION and UNION ALL are used to join the data from 2 or more tables but
UNION removes duplicate rows and picks the rows which are distinct after
combining the data from the tables whereas UNION ALL does not remove
the duplicate rows, it just picks all the data from the tables.
A Subquery is also known as a nested query i.e. a query written inside some
query. When a Subquery is executed for each of the rows of the outer query
then it is termed as a Correlated Subquery.
Here, the inner query is not executed for each of the rows of the outer query.
The entity is an object, place, or thing which has its independent existence in
the real world and about which data can be stored in a database. For
Example, any person, book, etc.
Entity Type is a collection of entities that have the same attributes. For
Example, the STUDENT table contains rows in which each row is an entity
holding the attributes like name, age, and id of the students, hence
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 9/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
STUDENT is an Entity Type that holds the entities having the same
attributes.
They include:
Physical Level: This is the lowest level of the data abstraction which states
how the data is stored in the database.
Logical Level: This is the next level of the data abstraction which states the
type of the data and the relationship among the data that is stored in the
database.
View Level: This is the highest level in the data abstraction which
shows/states only a part of the database.
There are two major integrity rules that exist in the DBMS.
Entity Integrity: This states a very important rule that the value of a Primary
key can never have a NULL value.
Referential Integrity: This rule is related to the Foreign key which states
that either the value of a Foreign key is a NULL value or it should be the
primary key of any other relation.
Example: If there is some relation ‘R1’ which has 2 attributes as Y and Z then
the functional dependency among these 2 attributes can be shown as Y-
>Z which states that Z is functionally dependent on Y.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 10/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
This is the easiest form of the normalization process which states that
the domain of an attribute should have only atomic values. The objective of
this is to remove the duplicate columns that are present in the table.
Any table is said to have in the 2NF if it satisfies the following 2 conditions:
Any table is said to have in the 3NF if it satisfies the following 2 conditions:
BCNF is the Boyce Codd Normal Form which is stricter than the 3NF.
For each of the functional dependencies X->Y that exists, X is the super key
of a table.
This is used with the SQL queries to fetch specific data as per the
requirements on the basis of the conditions that are put in the SQL. This is
very helpful in picking the selective records from the complete set of
records.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 11/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
For Example, There is a query that has a WHERE condition or the query with
the HAVING clause.
42.How can you get the alternate records from the table in the SQL?
If you want to fetch the odd numbers then the following query can be used:
If you want to fetch the even numbers, then the following query can be used:
Answer: With the help of the LIKE operator, pattern matching is possible in
the SQL.’%’ is used with the LIKE operator when it matches with the 0 or
more characters, and ‘_’ is used to match the one particular character.
Example:
A Join is one of the SQL statements which is used to join the data or the
rows from 2 or more tables on the basis of a common field/column among
them.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 12/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
Inner Join: This type of join is used to fetch the data among the tables which
are common in both tables.
Left Join: This returns all the rows from the table which is on the left side of
the join but only the matching rows from the table which is on the right side
of the join.
Right Join: This returns all the rows from the table which is on the right side
of the join but only the matching rows from the table which is on the left
side of the join.
Full Join: This returns the rows from all the tables on which the join
condition has been put and the rows which do not match hold null values.
One-to-Many: This states that there can be many relationships for one i.e. a
primary key table hold only one record which can have many, one, or none
records in the related table.
Many-to-Many: This states that both the tables can be related to many
other tables.
Compilation of similar entity types into one particular type which is grouped
together as an entity set is known as entity type extension.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 13/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
Conceptual design is the first stage in the database design process. The goal
at this stage is to design a database that is independent of database
software and physical details. The output of this process is a conceptual
data model that describes the main data entities, attributes, relationships,
and constraints of a given problem domain.
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 14/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
The database design is divided into several phases. The logical database
design and physical database design are two of them. This separation is
generally based on the concept of the three-level architecture of DBMS,
which provides data independence. Therefore, we can say that this
separation leads to data independence because the output of the logical
database design is the conceptual and external level schemas of
the database system which is independent of the output of the physical
database design that is an internal schema.
53. Explain different types of failures that occur in the Oracle database.
Types of Failures – In the Oracle database following types of failures can
occur:
Statement Failure·
Bad data type
Insufficient space
Insufficient Privileges (e.g., object privileges to a role)
User Process Failure
The user performed an abnormal disconnect
The user’s session was abnormally terminated
The user’s program raised an address exception
User Error
The user drops a table
User damages data by modification
Instance Failure
Media Failure
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 15/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
RAID is a method of combining several hard disk drives into one logical unit
(two or more disks grouped together to appear as a single device to the host
system). RAID technology was developed to address the fault-tolerance and
performance limitations of conventional disk storage. It can offer fault
tolerance and higher throughput levels than a single hard drive or group of
independent hard drives. While arrays were once considered complex and
relatively specialized storage solutions, today they are easy to use and
essential for a broad spectrum of client/server applications.
"GeeksforGeeks helped me ace the GATE exam! Whenever I had any doubt
regarding any topic, GFG always helped me and made my concepts quiet
clear." - Anshika Modi | AIR 21
GeeksforGeeks 292
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 16/20
7/23/24, 10:33 AM Commonly asked DBMS interview questions|Set 1
Similar Reads
Commonly asked DBMS interview questions | Set 2
This article is an extension of Commonly asked DBMS interview questions |
Set 1. Q. There is a table where only one row is fully repeated. Write a Query…
5 min read
Company Explore
About Us Job-A-Thon Hiring Challenge
Legal Hack-A-Thon
Careers GfG Weekly Contest
In Media Offline Classes (Delhi/NCR)
Contact Us DSA in JAVA/C++
Advertise with us Master System Design
GFG Corporate Solution Master CP
Placement Training Program GeeksforGeeks Videos
Geeks Community
Languages DSA
Python Data Structures
Java Algorithms
C++ DSA for Beginners
PHP Basic DSA Problems
GoLang DSA Roadmap
SQL DSA Interview Questions
R Language Competitive Programming
Android Tutorial
https://www.geeksforgeeks.org/commonly-asked-dbms-interview-questions/ 20/20