SlideShare a Scribd company logo
1 of 142
www.edureka.co/mysql-dba
FIRST SLIDE
www.edureka.co/mysql-dbaMySQL DBA Certification Training
2.5 x 1018 Bytes
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Database Administrators
Core of Relational
Databases
www.edureka.co/mysql-dba
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
SQL
Interview Questions
Whatisthedifference between
DELETEandTRUNCATEstatements?
Question 1
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 1
Whatisthedifference between
DELETEandTRUNCATEstatements?
SQL
Interview Questions Delete
✓ Delete command is used to delete a row in a table.
✓ You can rollback data after using delete statement.
✓ It is a DML command.
✓ It is slower than truncate statement.
Truncate
✓ Truncate is used to delete all the rows from a table.
✓ You cannot rollback data.
✓ It is a DDL command.
✓ It is faster.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatarethedifferentsubsetsof
SQL?
Question 2
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatarethedifferentsubsetsof
SQL?
Question 2
SQL
Interview Questions
DDL DML
DCL TCL
Consists of the commands
that can be used to define
the database schema.
Consists of commands that
deals with the
manipulation of data
present in database.
Includes the commands
which mainly deal with the
transaction of database.
Includes commands which
deal with the rights,
permissions and other
controls of the database
system.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatdoyoumeanbyDBMS?What
areitsdifferenttypes?
Question 3
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 3
WhatdoyoumeanbyDBMS?What
areitsdifferenttypes?
SQL
Interview Questions
A Database Management System (DBMS) is a software application that
interacts with the user, applications and the database itself to capture
and analyse data. The data stored in the database can be modified,
retrieved and deleted, and can be of any type like strings, numbers,
images etc.
HIERARCHIAL NETWORK
OBJECT-ORIENTEDRELATIONAL
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatdoyoumeanbytableand
fieldinSQL?
Question 4
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 4
Whatdoyoumeanbytableand
fieldinSQL?
SQL
Interview Questions
A table refers to a collection of data in an organised manner
in form of rows and columns.
Table
A field refers to the number of columns in a table.
Field
EMP_NO EMP_NAME EMP_COUNTRY EMP_AGE
1 Rohan India 23
2 Rohan India 34
3 Anay India 27
4 Suhana India 25
EMPLOYEE_INFORMATION
Table
Field
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatarejoinsinSQL?
Question 5
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 5
WhatarejoinsinSQL?
SQL
Interview Questions A JOIN clause is used to combine rows from two or more tables, based on
a related column between them. It is used to merge two tables or retrieve
data from there.
There are 4 joins in SQL namely:
FULL JOIN
RIGHT JOIN
INNER JOIN
LEFT JOIN
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatisthedifference between
CHARandVARCHAR2datatypein
SQL?
Question 6
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 6
Whatisthedifference between
CHARandVARCHAR2datatypein
SQL?
SQL
Interview Questions
Varchar2Char
CHARACTER DATATYPE
Char is used for strings of fixed length. For example,
char(10) can only store 10 characters and will not be able
to store a string of any other length.
Char
Varchar2 is used for character strings of variable length.
For example varchar2(10) can store any length i.e. 6,8,2 in
this variable.
Varchar2
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatisaPrimarykey?
Question 7
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 7
WhatisaPrimarykey?
SQL
Interview Questions A set of attributes that can be used to uniquely identify every tuple is a
primary key. So, if there are 3-4 candidate keys present in a relationship,
then out of those, one can be chosen as a primary key.
EMP_NO EMP_NAME EMP_COUNTRY EMP_AGE
1 Rohan India 23
2 Rohan India 34
3 Anay India 27
4 Suhana India 25
EMPLOYEE_INFORMATION
Primary Key
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatareConstraints?
Question 8
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 8
WhatareConstraints?
SQL
Interview Questions
NOT NULL
Ensures that a NULL value
cannot be stored in a column
UNIQUE
This constraint makes sure that all
the values in a column are different
CHECK
This constraint ensures that all the values in a column
satisfy a specific condition.
DEFAULT
This constraint consists of a set of default values
for a column when no value is specified.
INDEX This constraint is used to create and retrieve data
from the database very quickly.
Constraints are used to specify the limit on the data type of the table. It
can be specified while creating or altering the table statement.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatisthedifference betweenSQL
andMySQL?
Question 9
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 9
Whatisthedifference betweenSQL
andMySQL?
SQL
Interview Questions
SQL
is a standard language which stands for Structured Query Language based on the English
language. SQL is the core of relational database which is used for accessing and managing
database.
MySQL
MySQL is an open-source relational database management system that works on many
platforms. It provides multi-user access to support many storage engines and is backed by
Oracle.
v/s
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatisaUniquekey?
Question 10
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 10
WhatisaUniquekey?
SQL
Interview Questions
Uniquely identifies a single row in the table.
Multiple values allowed per table.
Null values are allowed.
Duplicate values are not allowed.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatisaForeignkey?
Question 11
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 11
WhatisaForeignkey?
SQL
Interview Questions
Foreign key maintains referential integrity by enforcing a link between
the data in two tables.
The foreign key in the child table references the primary key in the
parent table.
The foreign key constraint prevents actions that would destroy links
between the child and parent tables.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatdoyoumeanbydata
integrity?
Question 12
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 12
Whatdoyoumeanbydata
integrity?
Data Integrity
SQL
Interview Questions
Defines
Accuracy of data
Consistency of data
Integrity Constraints to enforce
business rules on data.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatisthedifference between
clusteredandnonclusteredindex
inSQL?
Question 13
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 13
Whatisthedifference between
clusteredandnonclusteredindex
inSQL?
SQL
Interview Questions Clustered Index
Non Clustered Index
✓ Clustered index is used for easy retrieval of data from the
database and is faster.
✓ Clustered index alters the way records are stored in a
database as it sorts out rows by the column which is set to be
clustered index
✓ One table can only have one clustered index.
✓ Non-Clustered index is used for easy retrieval of data from the
database and is slower.
✓ Non clustered index does not alter the way it was stored but it
creates a separate object within a table which points back to
the original table rows after searching..
✓ One table can have many non-clustered indexes.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 14
WriteaSQLquerytodisplaythe
currentdate?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 14
WriteaSQLquerytodisplaythe
currentdate?
SQL
Interview Questions
In SQL, there is a built-in function called GetDate() which helps to return
the current timestamp/date.
Syntax GETDATE ( )
SQL Server 2017, SQL Server 2016, SQL
Server 2014, SQL Server 2012, SQL
Server 2008 R2, SQL Server 2008, SQL
Server 2005
Applies To
Example
SELECT GETDATE();
Result: ‘2019-03-18 18:17:28.160'
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 15
Whatarethedifferenttypeofjoins?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 15
Whatarethedifferenttypeofjoins?
SQL
Interview Questions
INNER JOIN
This join returns those
records which have
matching values in both
the tables.
FULL JOIN
This join returns all those
records which either
have a match in the left
or the right table.
LEFT JOIN
This join returns records
from the left table, and
also those records which
satisfy the condition from
the right table.
RIGHT JOIN
This join returns records
from the right table, and
also those records which
satisfy the condition from
the left table.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 16
Whatdoyoumeanby
Denormalization?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 16
Whatdoyoumeanby
Denormalization?
SQL
Interview Questions
refers to a technique which is used to access data from higher to lower
forms of a database.
Denormalization
Increase the performance of the entire
infrastructure as it introduces redundancy into a
table.
Adds the redundant data into a table by
incorporating database queries that combine
data from various tables into a single table.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 17
WhatareEntitiesand
Relationships?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 17
WhatareEntitiesand
Relationships?
SQL
Interview Questions Entities
A person, place, or thing in the real world about which data can be
stored in a database. Tables store data that represents one type of
entity. For example – A bank database has a customer table to store
customer information. Customer table stores this information as a
set of attributes (columns within the table) for each customer.
Relationships
Relation or links between entities that have something to do with
each other. For example – The customer name is related to the
customer account number and contact information, which might be
in the same table. There can also be relationships between separate
tables (for example, customer to accounts).
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 18
WhatisanIndex?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 18
WhatisanIndex?
SQL
Interview Questions
Index
Performance Tuning Method
Allows faster retrieval of records
from the table
Creates an entry for each value
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 19
Explaindifferenttypesofindex.
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 19
Explaindifferenttypesofindex.
SQL
Interview Questions
This index does not allow the field to have duplicate values if the
column is unique indexed. If a primary key is defined, a unique index
can be applied automatically.
This index reorders the physical order of the table and searches
based on the basis of key values. Each table can only have one
clustered index.
Non-Clustered Index does not alter the physical order of the table
and maintains a logical order of the data. Each table can have many
non-clustered indexes.
Unique Index
Clustered Index
Non-Clustered Index
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 20
WhatisNormalizationandwhatare
theadvantagesofit?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 20
WhatisNormalizationandwhatare
theadvantagesofit?
SQL
Interview Questions
❑Better database organization
❑More tables with smaller rows
❑Efficient data access
❑Greater flexibility for queries
❑Quickly find the information
❑Easier to implement security
❑Allows easy modification
❑Reduction of redundant and duplicate data
❑More compact database
❑Ensure consistent data after modification
Normalization is the process of organizing data to avoid duplication and
redundancy.
Advantages
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 21
Whatisthedifference between
DROPandTRUNCATEcommands?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 21
Whatisthedifference between
DROPandTRUNCATEcommands?
SQL
Interview Questions DROP
TRUNCATE
Removes a table and it cannot be rolled back from the database
Removes all rows from the table and cannot be rolled back into
the database;
DROP object object_nameSyntax
TRUNCATE TABLE table_name;Syntax
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
BCNF
3 NF
2 NF
1 NF
There are mainly four types of normalizations: INF, 2NF, 3NF & BCNF.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
Salutation Full Name Address
Movies
Rented
Category
Ms. Alice Johnson 1st Street
House No 3
Mission
Impossible:
Fallout, Clash
of Titans
Action, Action
Mr. David Allen 3rd Street 45 Interstellar,
Edge Of
Tomorrow
Sci-Fi, Sci-Fi
Mr. David Allen 7th Avenue Mission
Impossible:
Fallout
Action
Database Normalization Example
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
Each table cell should have a single value. So, basically all the records
must be unique.
Salutation Full Name Address Movies Rented
Ms. Alice Johnson
1st Street House
No 3
Mission
Impossible:
Fallout
Ms. Alice Johnson
1st Street House
No 3
Clash of Titans
Mr. David Allen 3rd Street 45 Interstellar
Mr. David Allen 3rd Street 45
Edge Of
Tomorrow
Mr. David Allen 7th Avenue
Mission
Impossible:
Fallout
1NF
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
Database should be 1NF and should also have single column primary key.
2NF
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
The database should be in 2NF and must not have any transitive
functional dependencies.
3NF
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 22
Explaindifferenttypesof
Normalization.
SQL
Interview Questions
If your database is in 3rd Normal Form, there would be some scenarios
where anomalies would be present, if you have more than candidate
key. Then BCNF comes into role, where you divide your tables further so
that there would be only one candidate key present.
BCNF
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 23
WhatisACIDpropertyina
database?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 23
WhatisACIDpropertyina
database?
SQL
Interview Questions
Atomicity
Consistency
Isolation
Durability
A
C
I
D
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 24
Whatdoyoumeanby“Trigger”in
SQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 24
Whatdoyoumeanby“Trigger”in
SQL?
SQL
Interview Questions Trigger in SQL are a special type of stored procedures that are defined to
execute automatically in place or after data modifications. It allows you
to execute a batch of code when an insert, update or any other query is
executed against a specific table.
AFTER INSERT – activated after data is inserted into the table
BEFORE UPDATE – activated before data in the table is updated
AFTER UPDATE – activated after the data in table is updated
BEFORE DELETE – activated before data is removed from the table
AFTER DELETE – activated after data is removed from the table
BEFORE INSERT – activated before data is inserted into the table
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 25
Whatarethedifferentoperators
availableinSQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 25
Whatarethedifferentoperators
availableinSQL?
SQL
Interview Questions
01
02
03
04
05
Arithmetic Operators
Bitwise Operators
Comparison Operators
Compound Operators
Logical Operators
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 26
AreNULLvaluessameasthatof
zeroorablankspace?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 26
AreNULLvaluessameasthatof
zeroorablankspace?
SQL
Interview Questions
A NULL value is not at all same as
that of zero or a blank space.
NULL value represents a value which is
unavailable, unknown, assigned or not
applicable whereas a zero is a number
and blank space is a character.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 27
Whatisthedifference between
crossjoinandnaturaljoin?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 27
Whatisthedifference between
crossjoinandnaturaljoin?
SQL
Interview Questions
Cross Join
Natural Join
Produces the cross product or Cartesian
product of two tables
Based on all the columns having the same
name and data types in both the tables.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 28
WhatissubqueryinSQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 28
WhatissubqueryinSQL?
SQL
Interview Questions
A subquery is a query inside another query where a query is defined to
retrieve data or information back from the database.
Subqueries are always executed first and the result of the subquery is passed
on to the main query.
SELECT lastname, firstname
FROM employees
WHERE addressCode IN (SELECT addressCode
FROM office
WHERE country = “INDIA”)
OUTER QUERY SUBQUERY OR INNER QUERY
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 29
Whatarethedifferenttypesofa
subquery?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 29
Whatarethedifferenttypesofa
subquery?
SQL
Interview Questions
This query is an independent query where the
output of subquery is substituted in the main
query.
Correlated Subquery
These are queries which select the data from a
table referenced in the outer query. It is not
considered as an independent query as it refers to
another table and refers the column in a table.
Non - Correlated Subquery
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 30
Canyoulistthewaystogetthe
countofrecordsinatable?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 30
Canyoulistthewaystogetthe
countofrecordsinatable?
SQL
Interview Questions To count the number of records in a table, you can use the below
commands:
SELECT * FROM table1;
SELECT COUNT(*) FROM table1;
SELECT rows FROM sysindexes WHERE id =
OBJECT_ID(table1) AND indid < 2
www.edureka.co/mysql-dbaMySQL DBA Certification Training
SQL
Interview Questions
WriteaSQLquerytofindthenames
ofemployeesthatbeginwith‘A’?
Question 31
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 31
WriteaSQLquerytofindthenames
ofemployeesthatbeginwith‘A’?
SQL
Interview Questions To display name of the employees that begin with ‘A’, type in the
below command:
SELECT * FROM Table_name WHERE EmpName like'A%'
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WriteaSQLquerytogetthethird
highestsalaryofanemployeefrom
employee_table?
Question 32
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WriteaSQLquerytogetthethird
highestsalaryofanemployeefrom
employee_table?
Question 32
SQL
Interview Questions
SELECT TOP 1 salary
FROM(
SELECT TOP 3 salary
FROM employee_table
ORDER BY salary DESC) AS emp
ORDER BY salary ASC;
You can write a query as follows:
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatistheneedforgroup
functionsinSQL?
Question 33
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 33
Whatistheneedforgroup
functionsinSQL?
SQL
Interview Questions Group functions work on the set of rows and returns one
result per group.
Some of the commonly used group functions are:
1
3
5
2
4
AVG
COUNT
MAX
MIN
SUM
6VARIANCE
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatisaRelationshipandwhat
arethedifferenttypeof
relationships?
Question 34
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 34
WhatisaRelationshipandwhat
arethedifferenttypeof
relationships?
SQL
Interview Questions Relation or links are between entities that have something to do with each
other. Relationships are defined as the connection between the tables in a
database.
One to Many
Relationship
One to One Relationship
Many to One
Relationship
Self-Referencing
Relationship
Relationships
www.edureka.co/mysql-dbaMySQL DBA Certification Training
HowcanyouinsertNULLvaluesina
columnwhileinsertingthedata?
Question 35
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 35
HowcanyouinsertNULLvaluesina
columnwhileinsertingthedata?
SQL
Interview Questions NULL values can be inserted in the following ways:
01
02
Implicitly by omitting column from column list
Explicitly by specifying NULL keyword in the
VALUES clause
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatisthemaindifference
between‘BETWEEN’and‘IN’
conditionoperators?
Question 36
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 36
Whatisthemaindifference
between‘BETWEEN’and‘IN’
conditionoperators?
SQL
Interview Questions BETWEEN
IN
Used to display rows based on a range of values in a row
Used to check for values contained in a specific set of values.
Example of BETWEEN:
SELECT * FROM Students where ROLL_NO BETWEEN 10
AND 50
Example of IN:
SELECT * FROM students where ROLL_NO IN
(8,15,25);
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhyareSQLfunctionsused?
Question 37
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 37
WhyareSQLfunctionsused?
SQL functions are used for the following purposes:
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatistheneedofMERGE
statement?
Question 38
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 38
WhatistheneedofMERGE
statement?
SQL
Interview Questions
Allows conditional update or
insertion of data into a table.
It performs an UPDATE if a row
exists, or an INSERT if the row does
not exist.
MERGE
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatdoyoumeanbyrecursive
storedprocedure?
Question 39
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 39
Whatdoyoumeanbyrecursive
storedprocedure?
SQL
Interview Questions
Recursive stored procedure refers to a stored
procedure which calls by itself until it reaches
some boundary condition.
This recursive function or procedure helps the
programmers to use the same set of code n
number of times.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
WhatisCLAUSEinSQL?
Question 40
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 40
WhatisCLAUSEinSQL?
SQL
Interview Questions
SQL clause helps to limit the result set by
providing a condition to the query. A clause
helps to filter the rows from the entire set
of records.
Example:
WHERE & HAVING clause
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatisthedifference between
‘HAVING’CLAUSEanda‘WHERE’
CLAUSE?
Question 41
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 41
Whatisthedifference between
‘HAVING’CLAUSEanda‘WHERE’
CLAUSE?
SQL
Interview Questions
HAVING CLAUSE
WHERE CLAUSE
Can be used only with SELECT statement. It is usually used in a
GROUP BY clause.
WHERE Clause is applied to each row before they are a part of
the GROUP BY function in a query.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Listthewaysinwhich Dynamic
SQLcanbeexecuted.
Question 42
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 42
Listthewaysinwhich Dynamic
SQLcanbeexecuted.
SQL
Interview Questions
Following are the ways in which dynamic SQL can be
executed:
01
02
03
Write a query with parameters
Using EXEC
Using sp_executesql
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Whatarethevariouslevelsof
constraints?
Question 43
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 43
Whatarethevariouslevelsof
constraints?
SQL
Interview Questions Constraints are the representation of a column to enforce data
entity and consistency.
There are two levels of a constraint, namely:
01
02
Column Level Constraint
Table Level Constraint
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 44
Howcanyoufetchcommonrecords
fromtwotables?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 44
Howcanyoufetchcommonrecords
fromtwotables?
SQL
Interview Questions You can fetch common records from two tables using INTERSECT.
Syntax
SELECT column1 , column2 ....
FROM table_names
WHERE condition
INTERSECT
SELECT column1 , column2 ....
FROM table_names
WHERE condition
Example
Select studentID from student INTERSECT Select
StudentID from Exam
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 45
Listsomecasemanipulation
functionsinSQL.
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 45
Listsomecasemanipulation
functionsinSQL.
SQL
Interview Questions
This function returns the string in lowercase. It takes a string as an
argument and returns it by converting it into lower case.
Syntax: LOWER(‘string’)
This function returns the string in uppercase. It takes a string as an
argument and returns it by converting it into uppercase.
Syntax: UPPER(‘string’)
This function returns the string with the first letter in uppercase and
rest of the letters in lowercase.
Syntax: INITCAP(‘string’)
LOWER
UPPER
INITCAP
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 46
Whatarethedifferentset
operatorsavailableinSQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 46
Whatarethedifferentset
operatorsavailableinSQL?
SQL
Interview Questions
Set Operations
LEFT QUERY RIGHT QUERY
Combines rows from both
the queries
UNION
FINAL RESULT
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 46
Whatarethedifferentset
operatorsavailableinSQL?
SQL
Interview Questions
Set Operations
LEFT QUERY
RIGHT QUERY
INTERSECT
FINAL RESULT
Keeps only those rows
which are common in
both the queries.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 46
Whatarethedifferentset
operatorsavailableinSQL?
SQL
Interview Questions
Set Operations
LEFT QUERY
RIGHT QUERY
MINUS
FINAL RESULT
Keeps rows from the left
query which are not
included in the right
query
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 47
WhatisanALIAScommand?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 47
WhatisanALIAScommand?
SQL
Interview Questions ALIAS name can be given to any table or a column. This alias
name can be referred in WHERE clause to identify a particular
table or a column.
Select emp.empID, dept.Result from employee
emp, department as dept where
emp.empID=dept.empID
Example
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 48
Whatareaggregateandscalar
functions?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 48
Whatareaggregateandscalar
functions?
SQL
Interview Questions
Scalar functions return a single value based on the input
value.
AGGREGATE FUNCTIONS
SCALAR FUNCTIONS
Used to evaluate mathematical calculation and returns a
single value. These calculations are done from the
columns in a table.
Example : MAX(), COUNT()
Example : UCASE(), NOW()
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 49
Howcanyoufetchalternate
recordsfromatable?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 49
Howcanyoufetchalternate
recordsfromatable?
SQL
Interview Questions You can fetch alternate records i.e. both odd and even row
numbers.
Example : To display even numbers, use the following command:
Select studentId from (Select rowno, studentId
from student) where mod(rowno,2)=0
Now, to display odd numbers:
Select studentId from (Select rowno, studentId
from student) where mod(rowno,2)=1
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 50
Nametheoperatorwhichisusedin
thequeryforpatternmatching?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 50
Nametheoperatorwhichisusedin
thequeryforpatternmatching?
SQL
Interview Questions
LIKE operator is used for pattern matching.
%– It matches zero or more characters.
Example :
SELECT * FROM students WHERE studentname LIKE
‘a%’
_– It matches exactly one character.
Example :
SELECT * FROM student WHERE studentname LIKE
‘abc_’
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 51
Howcanyouselectuniquerecords
fromatable?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 51
Howcanyouselectuniquerecords
fromatable?
SQL
Interview Questions
You can select unique records from a table by using the
DISTINCT keyword.
Example :
SELECT DISTINCT studentID FROM Student;
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 52
Howcanyoufetchfirst5
charactersofthestring?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 52
Howcanyoufetchfirst5
charactersofthestring?
SQL
Interview Questions
There are a lot of ways to fetch characters from a string.
Example :
SELECT SUBSTRING(StudentName,1,5) as
studentname FROM student
SELECT RIGHT(StudentName,5) as studentname FROM
student
Use SUBSTRING()
Use RIGHT()
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 53
Whatisthemaindifference
betweenSQLandPL/SQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 53
Whatisthemaindifference
betweenSQLandPL/SQL?
SQL
Interview Questions
SQL
is a query language that allows you to issue a single query or execute a
single INSERT/UPDATE/DELETE
PL/SQL
is Oracle’s “Procedural Language” SQL, which allows you to write a full
program (loops, variables, etc.) to accomplish multiple operations such as
SELECTS/INSERTS/UPDATES/DELETES.
v/s
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 54
WhatisaView?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 54
WhatisaView?
SQL
Interview Questions
A view is a virtual table which consists of a subset of data contained in a
table. Since views are not present, it takes less space to store. View can
have data of one or more tables combined and it depends on the
relationship.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 55
WhatareViewsusedfor?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 55
WhatareViewsusedfor?
SQL
Interview Questions
01
02
03
04
A view refers to a logical snapshot based on a table or another
view.
It is used for the following reasons:
Restricting access to data
Making complex queries simple
Ensuring data independence
Providing different views of same data
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 56
WhatisaStoredProcedure?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 56
WhatisaStoredProcedure?
SQL
Interview Questions
A function which consists of many SQL statements to access the
database system.
Several SQL statements are consolidated into a stored
procedure and are executed whenever and wherever required.
This saves time and avoid writing code again and again.
Stored Procedures
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 57
Listsomeadvantagesand
disadvantagesofStored
Procedure.
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 57
Listsomeadvantagesand
disadvantagesofStored
Procedure.
SQL
Interview Questions
Advantages
Disadvantages
A Stored Procedure can be used as a modular programming
which means create once, store and call for several times
whenever it is required. This supports faster execution. It also
reduces network traffic and provides better security to the data.
The only disadvantage of Stored Procedure is that it can be
executed only in the database and utilizes more memory in the
database server.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 58
Listallthetypesofuser-defined
functions.
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 58
Listallthetypesofuser-defined
functions.
SQL
Interview Questions
There are three types of user-defined functions.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 59
WhatdoyoumeanbyCollation?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 59
WhatdoyoumeanbyCollation?
SQL
Interview Questions
Character data is sorted using the rules that define the correct
character sequence along with options for specifying case-
sensitivity, character width etc.
Collation is defined as a set of rules that determine how data can
be sorted as well as compared.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 60
Whatarethedifferenttypesof
CollationSensitivity?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 60
Whatarethedifferenttypesof
CollationSensitivity?
SQL
Interview Questions
Different types of Collation Sensitivity are as follows:
Case Sensitivity
Kana Sensitivity
Width Sensitivity
Accent Sensitivity
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 61
WhatareLocalandGlobal
variables?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 61
WhatareLocalandGlobal
variables?
SQL
Interview Questions
Local Variables
Global Variables
These variables can be used or exist only inside the function. These
variables are not used or referred by any other function.
These variables are the variables which can be accessed throughout the
program. Global variables cannot be created whenever that function is
called.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 62
WhatisAutoIncrementinSQL?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 62
WhatisAutoIncrementinSQL?
SQL
Interview Questions
Allows the user to create a unique number to get generated
whenever a new record is inserted into the table.
This keyword is usually required whenever PRIMARY KEY is
used.
AUTO INCREMENT keyword can be used in Oracle and IDENTITY
keyword can be used in SQL SERVER.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 63
WhatisaDatawarehouse?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 63
WhatisaDatawarehouse?
SQL
Interview Questions
Datawarehouse refers to a central repository of data where
the data is assembled from multiple sources of information.
Those data are consolidated, transformed and made available
for the mining as well as online processing.
Warehouse data also have a subset of data called Data Marts.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 64
Whatarethedifferent
authentication modesinSQL
Server?Howcanitbechanged?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 64
Whatarethedifferent
authentication modesinSQL
Server?Howcanitbechanged?
SQL
Interview Questions
Windows Mode Mixed Mode
Steps to change authentication mode in SQL Server:
❑Click Start-> Programs-> Microsoft SQL Server and click SQL Enterprise
Manager to run SQL Enterprise Manager from the Microsoft SQL Server
program group.
❑Then select the server from the Tools menu.
❑Select SQL Server Configuration Properties, and choose the Security
page.
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 65
WhatareSTUFFandREPLACE
function?
SQL
Interview Questions
www.edureka.co/mysql-dbaMySQL DBA Certification Training
Question 65
WhatareSTUFFandREPLACE
function?
SQL
Interview Questions STUFF FUNCTION
STUFF(string_expression,start, length,
replacement_characters)
This function is used to overwrite existing character or inserts a string into
another string.
REPLACE FUNCTION
REPLACE (string_expression, search_string,
replacement_string)
This function is used to replace the existing characters of all the
occurrences.
Top 65 SQL Interview Questions and Answers | Edureka

More Related Content

What's hot

Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssis
deepakk073
 

What's hot (20)

SQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | EdurekaSQL for Data Science Tutorial | Data Science Tutorial | Edureka
SQL for Data Science Tutorial | Data Science Tutorial | Edureka
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administration
 
A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets with Jules ...
A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets with Jules ...A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets with Jules ...
A Tale of Three Apache Spark APIs: RDDs, DataFrames, and Datasets with Jules ...
 
Power BI Interview Questions and Answers | Power BI Certification | Power BI ...
Power BI Interview Questions and Answers | Power BI Certification | Power BI ...Power BI Interview Questions and Answers | Power BI Certification | Power BI ...
Power BI Interview Questions and Answers | Power BI Certification | Power BI ...
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssis
 
Nosql databases
Nosql databasesNosql databases
Nosql databases
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
PostgreSQL Tutorial for Beginners | Edureka
PostgreSQL Tutorial for Beginners | EdurekaPostgreSQL Tutorial for Beginners | Edureka
PostgreSQL Tutorial for Beginners | Edureka
 
Nosql seminar
Nosql seminarNosql seminar
Nosql seminar
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Triggers in SQL | Edureka
Triggers in SQL | EdurekaTriggers in SQL | Edureka
Triggers in SQL | Edureka
 
SQL
SQLSQL
SQL
 
An Introduction To Oracle Database
An Introduction To Oracle DatabaseAn Introduction To Oracle Database
An Introduction To Oracle Database
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 

Similar to Top 65 SQL Interview Questions and Answers | Edureka

SQL Interview Questions and Answers for Business Analyst
SQL Interview Questions and Answers for Business AnalystSQL Interview Questions and Answers for Business Analyst
SQL Interview Questions and Answers for Business Analyst
HireQuotient
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
kaashiv1
 

Similar to Top 65 SQL Interview Questions and Answers | Edureka (20)

SQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdfSQL Interview Questions - InterviewBit.pdf
SQL Interview Questions - InterviewBit.pdf
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
SQL Interview Questions and Answers for Business Analyst
SQL Interview Questions and Answers for Business AnalystSQL Interview Questions and Answers for Business Analyst
SQL Interview Questions and Answers for Business Analyst
 
Enterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison PillEnterprise NoSQL: Silver Bullet or Poison Pill
Enterprise NoSQL: Silver Bullet or Poison Pill
 
Module02
Module02Module02
Module02
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Ebook12
Ebook12Ebook12
Ebook12
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
 
Dropping unique constraints in sql server
Dropping unique constraints in sql serverDropping unique constraints in sql server
Dropping unique constraints in sql server
 
Stretch db sql server 2016 (sn0028)
Stretch db   sql server 2016 (sn0028)Stretch db   sql server 2016 (sn0028)
Stretch db sql server 2016 (sn0028)
 
Sql server
Sql serverSql server
Sql server
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
Ebook11
Ebook11Ebook11
Ebook11
 
Postgresql
PostgresqlPostgresql
Postgresql
 
SQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George GrammatikosSQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George Grammatikos
 
DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3DEE 431 Introduction to Mysql Slide 3
DEE 431 Introduction to Mysql Slide 3
 
Stored procedure tunning
Stored procedure tunningStored procedure tunning
Stored procedure tunning
 
JSSUG: SQL Sever Index Tuning
JSSUG: SQL Sever Index TuningJSSUG: SQL Sever Index Tuning
JSSUG: SQL Sever Index Tuning
 
Ebook6
Ebook6Ebook6
Ebook6
 

More from Edureka!

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Top 65 SQL Interview Questions and Answers | Edureka

  • 3. www.edureka.co/mysql-dbaMySQL DBA Certification Training Database Administrators Core of Relational Databases
  • 5. www.edureka.co/mysql-dbaMySQL DBA Certification Training SQL Interview Questions Whatisthedifference between DELETEandTRUNCATEstatements? Question 1
  • 6. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 1 Whatisthedifference between DELETEandTRUNCATEstatements? SQL Interview Questions Delete ✓ Delete command is used to delete a row in a table. ✓ You can rollback data after using delete statement. ✓ It is a DML command. ✓ It is slower than truncate statement. Truncate ✓ Truncate is used to delete all the rows from a table. ✓ You cannot rollback data. ✓ It is a DDL command. ✓ It is faster.
  • 7. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatarethedifferentsubsetsof SQL? Question 2 SQL Interview Questions
  • 8. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatarethedifferentsubsetsof SQL? Question 2 SQL Interview Questions DDL DML DCL TCL Consists of the commands that can be used to define the database schema. Consists of commands that deals with the manipulation of data present in database. Includes the commands which mainly deal with the transaction of database. Includes commands which deal with the rights, permissions and other controls of the database system.
  • 9. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatdoyoumeanbyDBMS?What areitsdifferenttypes? Question 3 SQL Interview Questions
  • 10. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 3 WhatdoyoumeanbyDBMS?What areitsdifferenttypes? SQL Interview Questions A Database Management System (DBMS) is a software application that interacts with the user, applications and the database itself to capture and analyse data. The data stored in the database can be modified, retrieved and deleted, and can be of any type like strings, numbers, images etc. HIERARCHIAL NETWORK OBJECT-ORIENTEDRELATIONAL
  • 11. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatdoyoumeanbytableand fieldinSQL? Question 4 SQL Interview Questions
  • 12. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 4 Whatdoyoumeanbytableand fieldinSQL? SQL Interview Questions A table refers to a collection of data in an organised manner in form of rows and columns. Table A field refers to the number of columns in a table. Field EMP_NO EMP_NAME EMP_COUNTRY EMP_AGE 1 Rohan India 23 2 Rohan India 34 3 Anay India 27 4 Suhana India 25 EMPLOYEE_INFORMATION Table Field
  • 13. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatarejoinsinSQL? Question 5 SQL Interview Questions
  • 14. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 5 WhatarejoinsinSQL? SQL Interview Questions A JOIN clause is used to combine rows from two or more tables, based on a related column between them. It is used to merge two tables or retrieve data from there. There are 4 joins in SQL namely: FULL JOIN RIGHT JOIN INNER JOIN LEFT JOIN
  • 15. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatisthedifference between CHARandVARCHAR2datatypein SQL? Question 6 SQL Interview Questions
  • 16. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 6 Whatisthedifference between CHARandVARCHAR2datatypein SQL? SQL Interview Questions Varchar2Char CHARACTER DATATYPE Char is used for strings of fixed length. For example, char(10) can only store 10 characters and will not be able to store a string of any other length. Char Varchar2 is used for character strings of variable length. For example varchar2(10) can store any length i.e. 6,8,2 in this variable. Varchar2
  • 17. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatisaPrimarykey? Question 7 SQL Interview Questions
  • 18. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 7 WhatisaPrimarykey? SQL Interview Questions A set of attributes that can be used to uniquely identify every tuple is a primary key. So, if there are 3-4 candidate keys present in a relationship, then out of those, one can be chosen as a primary key. EMP_NO EMP_NAME EMP_COUNTRY EMP_AGE 1 Rohan India 23 2 Rohan India 34 3 Anay India 27 4 Suhana India 25 EMPLOYEE_INFORMATION Primary Key
  • 19. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatareConstraints? Question 8 SQL Interview Questions
  • 20. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 8 WhatareConstraints? SQL Interview Questions NOT NULL Ensures that a NULL value cannot be stored in a column UNIQUE This constraint makes sure that all the values in a column are different CHECK This constraint ensures that all the values in a column satisfy a specific condition. DEFAULT This constraint consists of a set of default values for a column when no value is specified. INDEX This constraint is used to create and retrieve data from the database very quickly. Constraints are used to specify the limit on the data type of the table. It can be specified while creating or altering the table statement.
  • 21. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatisthedifference betweenSQL andMySQL? Question 9 SQL Interview Questions
  • 22. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 9 Whatisthedifference betweenSQL andMySQL? SQL Interview Questions SQL is a standard language which stands for Structured Query Language based on the English language. SQL is the core of relational database which is used for accessing and managing database. MySQL MySQL is an open-source relational database management system that works on many platforms. It provides multi-user access to support many storage engines and is backed by Oracle. v/s
  • 23. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatisaUniquekey? Question 10 SQL Interview Questions
  • 24. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 10 WhatisaUniquekey? SQL Interview Questions Uniquely identifies a single row in the table. Multiple values allowed per table. Null values are allowed. Duplicate values are not allowed.
  • 25. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatisaForeignkey? Question 11 SQL Interview Questions
  • 26. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 11 WhatisaForeignkey? SQL Interview Questions Foreign key maintains referential integrity by enforcing a link between the data in two tables. The foreign key in the child table references the primary key in the parent table. The foreign key constraint prevents actions that would destroy links between the child and parent tables.
  • 27. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatdoyoumeanbydata integrity? Question 12 SQL Interview Questions
  • 28. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 12 Whatdoyoumeanbydata integrity? Data Integrity SQL Interview Questions Defines Accuracy of data Consistency of data Integrity Constraints to enforce business rules on data.
  • 29. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatisthedifference between clusteredandnonclusteredindex inSQL? Question 13 SQL Interview Questions
  • 30. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 13 Whatisthedifference between clusteredandnonclusteredindex inSQL? SQL Interview Questions Clustered Index Non Clustered Index ✓ Clustered index is used for easy retrieval of data from the database and is faster. ✓ Clustered index alters the way records are stored in a database as it sorts out rows by the column which is set to be clustered index ✓ One table can only have one clustered index. ✓ Non-Clustered index is used for easy retrieval of data from the database and is slower. ✓ Non clustered index does not alter the way it was stored but it creates a separate object within a table which points back to the original table rows after searching.. ✓ One table can have many non-clustered indexes.
  • 31. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 14 WriteaSQLquerytodisplaythe currentdate? SQL Interview Questions
  • 32. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 14 WriteaSQLquerytodisplaythe currentdate? SQL Interview Questions In SQL, there is a built-in function called GetDate() which helps to return the current timestamp/date. Syntax GETDATE ( ) SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005 Applies To Example SELECT GETDATE(); Result: ‘2019-03-18 18:17:28.160'
  • 33. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 15 Whatarethedifferenttypeofjoins? SQL Interview Questions
  • 34. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 15 Whatarethedifferenttypeofjoins? SQL Interview Questions INNER JOIN This join returns those records which have matching values in both the tables. FULL JOIN This join returns all those records which either have a match in the left or the right table. LEFT JOIN This join returns records from the left table, and also those records which satisfy the condition from the right table. RIGHT JOIN This join returns records from the right table, and also those records which satisfy the condition from the left table.
  • 35. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 16 Whatdoyoumeanby Denormalization? SQL Interview Questions
  • 36. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 16 Whatdoyoumeanby Denormalization? SQL Interview Questions refers to a technique which is used to access data from higher to lower forms of a database. Denormalization Increase the performance of the entire infrastructure as it introduces redundancy into a table. Adds the redundant data into a table by incorporating database queries that combine data from various tables into a single table.
  • 37. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 17 WhatareEntitiesand Relationships? SQL Interview Questions
  • 38. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 17 WhatareEntitiesand Relationships? SQL Interview Questions Entities A person, place, or thing in the real world about which data can be stored in a database. Tables store data that represents one type of entity. For example – A bank database has a customer table to store customer information. Customer table stores this information as a set of attributes (columns within the table) for each customer. Relationships Relation or links between entities that have something to do with each other. For example – The customer name is related to the customer account number and contact information, which might be in the same table. There can also be relationships between separate tables (for example, customer to accounts).
  • 39. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 18 WhatisanIndex? SQL Interview Questions
  • 40. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 18 WhatisanIndex? SQL Interview Questions Index Performance Tuning Method Allows faster retrieval of records from the table Creates an entry for each value
  • 41. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 19 Explaindifferenttypesofindex. SQL Interview Questions
  • 42. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 19 Explaindifferenttypesofindex. SQL Interview Questions This index does not allow the field to have duplicate values if the column is unique indexed. If a primary key is defined, a unique index can be applied automatically. This index reorders the physical order of the table and searches based on the basis of key values. Each table can only have one clustered index. Non-Clustered Index does not alter the physical order of the table and maintains a logical order of the data. Each table can have many non-clustered indexes. Unique Index Clustered Index Non-Clustered Index
  • 43. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 20 WhatisNormalizationandwhatare theadvantagesofit? SQL Interview Questions
  • 44. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 20 WhatisNormalizationandwhatare theadvantagesofit? SQL Interview Questions ❑Better database organization ❑More tables with smaller rows ❑Efficient data access ❑Greater flexibility for queries ❑Quickly find the information ❑Easier to implement security ❑Allows easy modification ❑Reduction of redundant and duplicate data ❑More compact database ❑Ensure consistent data after modification Normalization is the process of organizing data to avoid duplication and redundancy. Advantages
  • 45. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 21 Whatisthedifference between DROPandTRUNCATEcommands? SQL Interview Questions
  • 46. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 21 Whatisthedifference between DROPandTRUNCATEcommands? SQL Interview Questions DROP TRUNCATE Removes a table and it cannot be rolled back from the database Removes all rows from the table and cannot be rolled back into the database; DROP object object_nameSyntax TRUNCATE TABLE table_name;Syntax
  • 47. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions
  • 48. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions BCNF 3 NF 2 NF 1 NF There are mainly four types of normalizations: INF, 2NF, 3NF & BCNF.
  • 49. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions Salutation Full Name Address Movies Rented Category Ms. Alice Johnson 1st Street House No 3 Mission Impossible: Fallout, Clash of Titans Action, Action Mr. David Allen 3rd Street 45 Interstellar, Edge Of Tomorrow Sci-Fi, Sci-Fi Mr. David Allen 7th Avenue Mission Impossible: Fallout Action Database Normalization Example
  • 50. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions Each table cell should have a single value. So, basically all the records must be unique. Salutation Full Name Address Movies Rented Ms. Alice Johnson 1st Street House No 3 Mission Impossible: Fallout Ms. Alice Johnson 1st Street House No 3 Clash of Titans Mr. David Allen 3rd Street 45 Interstellar Mr. David Allen 3rd Street 45 Edge Of Tomorrow Mr. David Allen 7th Avenue Mission Impossible: Fallout 1NF
  • 51. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions Database should be 1NF and should also have single column primary key. 2NF
  • 52. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions The database should be in 2NF and must not have any transitive functional dependencies. 3NF
  • 53. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 22 Explaindifferenttypesof Normalization. SQL Interview Questions If your database is in 3rd Normal Form, there would be some scenarios where anomalies would be present, if you have more than candidate key. Then BCNF comes into role, where you divide your tables further so that there would be only one candidate key present. BCNF
  • 54. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 23 WhatisACIDpropertyina database? SQL Interview Questions
  • 55. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 23 WhatisACIDpropertyina database? SQL Interview Questions Atomicity Consistency Isolation Durability A C I D
  • 56. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 24 Whatdoyoumeanby“Trigger”in SQL? SQL Interview Questions
  • 57. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 24 Whatdoyoumeanby“Trigger”in SQL? SQL Interview Questions Trigger in SQL are a special type of stored procedures that are defined to execute automatically in place or after data modifications. It allows you to execute a batch of code when an insert, update or any other query is executed against a specific table. AFTER INSERT – activated after data is inserted into the table BEFORE UPDATE – activated before data in the table is updated AFTER UPDATE – activated after the data in table is updated BEFORE DELETE – activated before data is removed from the table AFTER DELETE – activated after data is removed from the table BEFORE INSERT – activated before data is inserted into the table
  • 58. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 25 Whatarethedifferentoperators availableinSQL? SQL Interview Questions
  • 59. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 25 Whatarethedifferentoperators availableinSQL? SQL Interview Questions 01 02 03 04 05 Arithmetic Operators Bitwise Operators Comparison Operators Compound Operators Logical Operators
  • 60. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 26 AreNULLvaluessameasthatof zeroorablankspace? SQL Interview Questions
  • 61. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 26 AreNULLvaluessameasthatof zeroorablankspace? SQL Interview Questions A NULL value is not at all same as that of zero or a blank space. NULL value represents a value which is unavailable, unknown, assigned or not applicable whereas a zero is a number and blank space is a character.
  • 62. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 27 Whatisthedifference between crossjoinandnaturaljoin? SQL Interview Questions
  • 63. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 27 Whatisthedifference between crossjoinandnaturaljoin? SQL Interview Questions Cross Join Natural Join Produces the cross product or Cartesian product of two tables Based on all the columns having the same name and data types in both the tables.
  • 64. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 28 WhatissubqueryinSQL? SQL Interview Questions
  • 65. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 28 WhatissubqueryinSQL? SQL Interview Questions A subquery is a query inside another query where a query is defined to retrieve data or information back from the database. Subqueries are always executed first and the result of the subquery is passed on to the main query. SELECT lastname, firstname FROM employees WHERE addressCode IN (SELECT addressCode FROM office WHERE country = “INDIA”) OUTER QUERY SUBQUERY OR INNER QUERY
  • 66. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 29 Whatarethedifferenttypesofa subquery? SQL Interview Questions
  • 67. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 29 Whatarethedifferenttypesofa subquery? SQL Interview Questions This query is an independent query where the output of subquery is substituted in the main query. Correlated Subquery These are queries which select the data from a table referenced in the outer query. It is not considered as an independent query as it refers to another table and refers the column in a table. Non - Correlated Subquery
  • 68. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 30 Canyoulistthewaystogetthe countofrecordsinatable? SQL Interview Questions
  • 69. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 30 Canyoulistthewaystogetthe countofrecordsinatable? SQL Interview Questions To count the number of records in a table, you can use the below commands: SELECT * FROM table1; SELECT COUNT(*) FROM table1; SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2
  • 70. www.edureka.co/mysql-dbaMySQL DBA Certification Training SQL Interview Questions WriteaSQLquerytofindthenames ofemployeesthatbeginwith‘A’? Question 31
  • 71. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 31 WriteaSQLquerytofindthenames ofemployeesthatbeginwith‘A’? SQL Interview Questions To display name of the employees that begin with ‘A’, type in the below command: SELECT * FROM Table_name WHERE EmpName like'A%'
  • 72. www.edureka.co/mysql-dbaMySQL DBA Certification Training WriteaSQLquerytogetthethird highestsalaryofanemployeefrom employee_table? Question 32 SQL Interview Questions
  • 73. www.edureka.co/mysql-dbaMySQL DBA Certification Training WriteaSQLquerytogetthethird highestsalaryofanemployeefrom employee_table? Question 32 SQL Interview Questions SELECT TOP 1 salary FROM( SELECT TOP 3 salary FROM employee_table ORDER BY salary DESC) AS emp ORDER BY salary ASC; You can write a query as follows:
  • 74. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatistheneedforgroup functionsinSQL? Question 33 SQL Interview Questions
  • 75. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 33 Whatistheneedforgroup functionsinSQL? SQL Interview Questions Group functions work on the set of rows and returns one result per group. Some of the commonly used group functions are: 1 3 5 2 4 AVG COUNT MAX MIN SUM 6VARIANCE
  • 76. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatisaRelationshipandwhat arethedifferenttypeof relationships? Question 34 SQL Interview Questions
  • 77. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 34 WhatisaRelationshipandwhat arethedifferenttypeof relationships? SQL Interview Questions Relation or links are between entities that have something to do with each other. Relationships are defined as the connection between the tables in a database. One to Many Relationship One to One Relationship Many to One Relationship Self-Referencing Relationship Relationships
  • 78. www.edureka.co/mysql-dbaMySQL DBA Certification Training HowcanyouinsertNULLvaluesina columnwhileinsertingthedata? Question 35 SQL Interview Questions
  • 79. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 35 HowcanyouinsertNULLvaluesina columnwhileinsertingthedata? SQL Interview Questions NULL values can be inserted in the following ways: 01 02 Implicitly by omitting column from column list Explicitly by specifying NULL keyword in the VALUES clause
  • 80. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatisthemaindifference between‘BETWEEN’and‘IN’ conditionoperators? Question 36 SQL Interview Questions
  • 81. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 36 Whatisthemaindifference between‘BETWEEN’and‘IN’ conditionoperators? SQL Interview Questions BETWEEN IN Used to display rows based on a range of values in a row Used to check for values contained in a specific set of values. Example of BETWEEN: SELECT * FROM Students where ROLL_NO BETWEEN 10 AND 50 Example of IN: SELECT * FROM students where ROLL_NO IN (8,15,25);
  • 82. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhyareSQLfunctionsused? Question 37 SQL Interview Questions
  • 83. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 37 WhyareSQLfunctionsused? SQL functions are used for the following purposes: SQL Interview Questions
  • 84. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatistheneedofMERGE statement? Question 38 SQL Interview Questions
  • 85. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 38 WhatistheneedofMERGE statement? SQL Interview Questions Allows conditional update or insertion of data into a table. It performs an UPDATE if a row exists, or an INSERT if the row does not exist. MERGE
  • 86. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatdoyoumeanbyrecursive storedprocedure? Question 39 SQL Interview Questions
  • 87. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 39 Whatdoyoumeanbyrecursive storedprocedure? SQL Interview Questions Recursive stored procedure refers to a stored procedure which calls by itself until it reaches some boundary condition. This recursive function or procedure helps the programmers to use the same set of code n number of times.
  • 88. www.edureka.co/mysql-dbaMySQL DBA Certification Training WhatisCLAUSEinSQL? Question 40 SQL Interview Questions
  • 89. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 40 WhatisCLAUSEinSQL? SQL Interview Questions SQL clause helps to limit the result set by providing a condition to the query. A clause helps to filter the rows from the entire set of records. Example: WHERE & HAVING clause
  • 90. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatisthedifference between ‘HAVING’CLAUSEanda‘WHERE’ CLAUSE? Question 41 SQL Interview Questions
  • 91. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 41 Whatisthedifference between ‘HAVING’CLAUSEanda‘WHERE’ CLAUSE? SQL Interview Questions HAVING CLAUSE WHERE CLAUSE Can be used only with SELECT statement. It is usually used in a GROUP BY clause. WHERE Clause is applied to each row before they are a part of the GROUP BY function in a query.
  • 92. www.edureka.co/mysql-dbaMySQL DBA Certification Training Listthewaysinwhich Dynamic SQLcanbeexecuted. Question 42 SQL Interview Questions
  • 93. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 42 Listthewaysinwhich Dynamic SQLcanbeexecuted. SQL Interview Questions Following are the ways in which dynamic SQL can be executed: 01 02 03 Write a query with parameters Using EXEC Using sp_executesql
  • 94. www.edureka.co/mysql-dbaMySQL DBA Certification Training Whatarethevariouslevelsof constraints? Question 43 SQL Interview Questions
  • 95. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 43 Whatarethevariouslevelsof constraints? SQL Interview Questions Constraints are the representation of a column to enforce data entity and consistency. There are two levels of a constraint, namely: 01 02 Column Level Constraint Table Level Constraint
  • 96. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 44 Howcanyoufetchcommonrecords fromtwotables? SQL Interview Questions
  • 97. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 44 Howcanyoufetchcommonrecords fromtwotables? SQL Interview Questions You can fetch common records from two tables using INTERSECT. Syntax SELECT column1 , column2 .... FROM table_names WHERE condition INTERSECT SELECT column1 , column2 .... FROM table_names WHERE condition Example Select studentID from student INTERSECT Select StudentID from Exam
  • 98. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 45 Listsomecasemanipulation functionsinSQL. SQL Interview Questions
  • 99. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 45 Listsomecasemanipulation functionsinSQL. SQL Interview Questions This function returns the string in lowercase. It takes a string as an argument and returns it by converting it into lower case. Syntax: LOWER(‘string’) This function returns the string in uppercase. It takes a string as an argument and returns it by converting it into uppercase. Syntax: UPPER(‘string’) This function returns the string with the first letter in uppercase and rest of the letters in lowercase. Syntax: INITCAP(‘string’) LOWER UPPER INITCAP
  • 100. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 46 Whatarethedifferentset operatorsavailableinSQL? SQL Interview Questions
  • 101. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 46 Whatarethedifferentset operatorsavailableinSQL? SQL Interview Questions Set Operations LEFT QUERY RIGHT QUERY Combines rows from both the queries UNION FINAL RESULT
  • 102. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 46 Whatarethedifferentset operatorsavailableinSQL? SQL Interview Questions Set Operations LEFT QUERY RIGHT QUERY INTERSECT FINAL RESULT Keeps only those rows which are common in both the queries.
  • 103. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 46 Whatarethedifferentset operatorsavailableinSQL? SQL Interview Questions Set Operations LEFT QUERY RIGHT QUERY MINUS FINAL RESULT Keeps rows from the left query which are not included in the right query
  • 104. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 47 WhatisanALIAScommand? SQL Interview Questions
  • 105. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 47 WhatisanALIAScommand? SQL Interview Questions ALIAS name can be given to any table or a column. This alias name can be referred in WHERE clause to identify a particular table or a column. Select emp.empID, dept.Result from employee emp, department as dept where emp.empID=dept.empID Example
  • 106. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 48 Whatareaggregateandscalar functions? SQL Interview Questions
  • 107. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 48 Whatareaggregateandscalar functions? SQL Interview Questions Scalar functions return a single value based on the input value. AGGREGATE FUNCTIONS SCALAR FUNCTIONS Used to evaluate mathematical calculation and returns a single value. These calculations are done from the columns in a table. Example : MAX(), COUNT() Example : UCASE(), NOW()
  • 108. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 49 Howcanyoufetchalternate recordsfromatable? SQL Interview Questions
  • 109. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 49 Howcanyoufetchalternate recordsfromatable? SQL Interview Questions You can fetch alternate records i.e. both odd and even row numbers. Example : To display even numbers, use the following command: Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=0 Now, to display odd numbers: Select studentId from (Select rowno, studentId from student) where mod(rowno,2)=1
  • 110. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 50 Nametheoperatorwhichisusedin thequeryforpatternmatching? SQL Interview Questions
  • 111. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 50 Nametheoperatorwhichisusedin thequeryforpatternmatching? SQL Interview Questions LIKE operator is used for pattern matching. %– It matches zero or more characters. Example : SELECT * FROM students WHERE studentname LIKE ‘a%’ _– It matches exactly one character. Example : SELECT * FROM student WHERE studentname LIKE ‘abc_’
  • 112. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 51 Howcanyouselectuniquerecords fromatable? SQL Interview Questions
  • 113. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 51 Howcanyouselectuniquerecords fromatable? SQL Interview Questions You can select unique records from a table by using the DISTINCT keyword. Example : SELECT DISTINCT studentID FROM Student;
  • 114. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 52 Howcanyoufetchfirst5 charactersofthestring? SQL Interview Questions
  • 115. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 52 Howcanyoufetchfirst5 charactersofthestring? SQL Interview Questions There are a lot of ways to fetch characters from a string. Example : SELECT SUBSTRING(StudentName,1,5) as studentname FROM student SELECT RIGHT(StudentName,5) as studentname FROM student Use SUBSTRING() Use RIGHT()
  • 116. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 53 Whatisthemaindifference betweenSQLandPL/SQL? SQL Interview Questions
  • 117. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 53 Whatisthemaindifference betweenSQLandPL/SQL? SQL Interview Questions SQL is a query language that allows you to issue a single query or execute a single INSERT/UPDATE/DELETE PL/SQL is Oracle’s “Procedural Language” SQL, which allows you to write a full program (loops, variables, etc.) to accomplish multiple operations such as SELECTS/INSERTS/UPDATES/DELETES. v/s
  • 118. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 54 WhatisaView? SQL Interview Questions
  • 119. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 54 WhatisaView? SQL Interview Questions A view is a virtual table which consists of a subset of data contained in a table. Since views are not present, it takes less space to store. View can have data of one or more tables combined and it depends on the relationship.
  • 120. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 55 WhatareViewsusedfor? SQL Interview Questions
  • 121. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 55 WhatareViewsusedfor? SQL Interview Questions 01 02 03 04 A view refers to a logical snapshot based on a table or another view. It is used for the following reasons: Restricting access to data Making complex queries simple Ensuring data independence Providing different views of same data
  • 122. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 56 WhatisaStoredProcedure? SQL Interview Questions
  • 123. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 56 WhatisaStoredProcedure? SQL Interview Questions A function which consists of many SQL statements to access the database system. Several SQL statements are consolidated into a stored procedure and are executed whenever and wherever required. This saves time and avoid writing code again and again. Stored Procedures
  • 124. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 57 Listsomeadvantagesand disadvantagesofStored Procedure. SQL Interview Questions
  • 125. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 57 Listsomeadvantagesand disadvantagesofStored Procedure. SQL Interview Questions Advantages Disadvantages A Stored Procedure can be used as a modular programming which means create once, store and call for several times whenever it is required. This supports faster execution. It also reduces network traffic and provides better security to the data. The only disadvantage of Stored Procedure is that it can be executed only in the database and utilizes more memory in the database server.
  • 126. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 58 Listallthetypesofuser-defined functions. SQL Interview Questions
  • 127. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 58 Listallthetypesofuser-defined functions. SQL Interview Questions There are three types of user-defined functions.
  • 128. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 59 WhatdoyoumeanbyCollation? SQL Interview Questions
  • 129. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 59 WhatdoyoumeanbyCollation? SQL Interview Questions Character data is sorted using the rules that define the correct character sequence along with options for specifying case- sensitivity, character width etc. Collation is defined as a set of rules that determine how data can be sorted as well as compared.
  • 130. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 60 Whatarethedifferenttypesof CollationSensitivity? SQL Interview Questions
  • 131. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 60 Whatarethedifferenttypesof CollationSensitivity? SQL Interview Questions Different types of Collation Sensitivity are as follows: Case Sensitivity Kana Sensitivity Width Sensitivity Accent Sensitivity
  • 132. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 61 WhatareLocalandGlobal variables? SQL Interview Questions
  • 133. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 61 WhatareLocalandGlobal variables? SQL Interview Questions Local Variables Global Variables These variables can be used or exist only inside the function. These variables are not used or referred by any other function. These variables are the variables which can be accessed throughout the program. Global variables cannot be created whenever that function is called.
  • 134. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 62 WhatisAutoIncrementinSQL? SQL Interview Questions
  • 135. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 62 WhatisAutoIncrementinSQL? SQL Interview Questions Allows the user to create a unique number to get generated whenever a new record is inserted into the table. This keyword is usually required whenever PRIMARY KEY is used. AUTO INCREMENT keyword can be used in Oracle and IDENTITY keyword can be used in SQL SERVER.
  • 136. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 63 WhatisaDatawarehouse? SQL Interview Questions
  • 137. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 63 WhatisaDatawarehouse? SQL Interview Questions Datawarehouse refers to a central repository of data where the data is assembled from multiple sources of information. Those data are consolidated, transformed and made available for the mining as well as online processing. Warehouse data also have a subset of data called Data Marts.
  • 138. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 64 Whatarethedifferent authentication modesinSQL Server?Howcanitbechanged? SQL Interview Questions
  • 139. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 64 Whatarethedifferent authentication modesinSQL Server?Howcanitbechanged? SQL Interview Questions Windows Mode Mixed Mode Steps to change authentication mode in SQL Server: ❑Click Start-> Programs-> Microsoft SQL Server and click SQL Enterprise Manager to run SQL Enterprise Manager from the Microsoft SQL Server program group. ❑Then select the server from the Tools menu. ❑Select SQL Server Configuration Properties, and choose the Security page.
  • 140. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 65 WhatareSTUFFandREPLACE function? SQL Interview Questions
  • 141. www.edureka.co/mysql-dbaMySQL DBA Certification Training Question 65 WhatareSTUFFandREPLACE function? SQL Interview Questions STUFF FUNCTION STUFF(string_expression,start, length, replacement_characters) This function is used to overwrite existing character or inserts a string into another string. REPLACE FUNCTION REPLACE (string_expression, search_string, replacement_string) This function is used to replace the existing characters of all the occurrences.