SlideShare a Scribd company logo
1 of 7
Download to read offline
Interview Questions
Q 1. What is SQL? (TCS)
SQL stands for Structured Query Language. It is the standard language for relational
database management systems. It is especially useful in handling organized data
composed of entities (variables) and relations between different entities of the data.
Q 2. What are the different commands in SQL? (Myntra)
● Data Definition Language (DDL) – It allows you to perform various operations on
the database such as CREATE, ALTER, and DELETE objects.
● Data Manipulation Language(DML) – It allows you to access and manipulate data.
It helps you to insert, update, delete and retrieve data from the database.
● Data Control Language(DCL) – It allows you to control access to the database.
Example – Grant, Revoke access permissions.
● Transaction control Language(TCL)
Example - Rollback ,commit
Q 3. What are different types of DBMS? (Amazon)
There are two types of DBMS:
● Relational Database Management System: The data is stored in relations (tables).
Example – MySQL.
● Non-Relational Database Management System: There is no concept of relations,
tuples and attributes. Example – MongoDB
Q 4. What do you mean by table and field in SQL? (IBM)
A table refers to a collection of data in an organised manner in the form of rows and
columns. A field refers to the number of columns in a table.
Interview Questions
Q 1. How to change a table name in SQL? (Vmware)
This is the command to change a table name in SQL:
ALTER TABLE table_name
RENAME TO new_table_name;
Q 2. What is the difference between DELETE and TRUNCATE statements?
(Goldman Sachs)
DELETE TRUNCATE
Delete command is used to delete a row in
a table.
Truncate is used to delete all the rows
from a table.
You can rollback data after using the delete
statement.
You cannot rollback data.
It is a DML command. It is a DDL command.
It is slower than a truncated statement. It is faster.
Q 3. What is an Index? (Morgan Stanely)
An index refers to a performance tuning method of allowing faster retrieval of records
from the table. An index creates an entry for each value and hence it will be faster to
retrieve data.
Q 4. Explain different types of indexes in SQL. (Microsoft)
There are three types of index namely:
Unique Index:
This index does not allow the field to have duplicate values if the column is uniquely
indexed. If a primary key is defined, a unique index can be applied automatically.
Clustered Index:
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:
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 nonclustered indexes.
Q 5. Are NULL values the same as that of zero or a blank space? (VERITAS, TCS)
A NULL value is not at all the 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
Q 6. What are the different types of a subquery? (D.E.SHAW)
There are two types of subquery namely, Correlated and Non-Correlated.
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 to the column in a table.
Non-Correlated subquery: This query is an independent query where the output of the
subquery is substituted in the main query.
Q 7. Write a SQL query to find the names of employees that begin with ‘A’?
(ADOBE)
To display name of the employees that begin with ‘A’, type in the below command:
SELECT * FROM Table_name WHERE EmpName like 'A%';
Q 8. What is the need for group functions in SQL? (WIPRO)
Group functions work on the set of rows and return one result per group. Some of the
commonly used group functions are: AVG, COUNT, MAX, MIN, SUM, VARIANCE.
Q 9. How can you insert NULL values in a column while inserting the data?
(INTUIT)
NULL values in SQL can be inserted in the following ways:
● Implicitly by omitting column from column list.
● Explicitly by specifying NULL keyword in the VALUES clause
Q 10. What is the main difference between ‘BETWEEN’ and ‘IN’ condition
operators? (GOOGLE)
BETWEEN operator is used to display rows based on a range of values in a row whereas
the IN condition operator is used to check for values contained in a specific set of
values.
Q 11. What is the difference between ‘HAVING’ CLAUSE and a ‘WHERE’ CLAUSE?
(HSBC)
HAVING clause can be used only with a SELECT statement. It is usually used in a GROUP
BY clause and whenever GROUP BY is not used, HAVING behaves like a WHERE clause.
Having Clause is only used with the GROUP BY function in a query whereas WHERE
Clause is applied to each row before they are a part of the GROUP BY function in a
query.
Q 12. How can you select unique records from a table? (WALMART)
You can select unique records from a table by using the DISTINCT keyword.
Select DISTINCT studentID from Student
Using this command, it will print a unique student id from the table Student.
Q 13. Write a Query to display the number of employees working in each region?
(MASTERCARD)
SELECT region, COUNT(gender) FROM employee GROUP BY region;
Q 14. How to use LIKE in SQL? (BITWISE)
The LIKE operator checks if an attribute value matches a given string pattern. Here is an
example of LIKE operator
SELECT * FROM employees WHERE first_name like ‘Steven’;
With this command, we will be able to extract all the records where the first name is like
“Steven”.
Interview Questions
Q 1. What is a Primary key? (L&T)
● A Primary key is a column (or collection of columns) or a set of columns that
uniquely identifies each row in the table.
● Uniquely identifies a single row in the table
● Null values not allowed
Q 2. What is a Unique key? (Persistent)
● Uniquely identifies a single row in the table.
● Multiple values allowed per table.
● Null values allowed.
Q 3. What is a Foreign key in SQL? (Mastercard)
● 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.
Q 4. What is a View? (BAJAJ )
A view is a virtual table that consists of a subset of data contained in a table. Since views
are not present, it takes less space to store. Views can have data of one or more tables
combined and it depends on the relationship.
Q 5. What are Views used for? (AMAZON)
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 the same data.
Interview Questions
Q 1.If we drop a table, does it also drop related objects like constraints, indexes,
columns, default, views and stored procedures? (ZS)
Yes, SQL Server drops all related objects, which exist inside a table like constraints,
indexes, columns, defaults etc. But dropping a table will not drop views and stored
procedures as they exist outside the table.
Q 2. What is a join? (MICROSOFT)
This is a keyword used to query data from more tables based on the relationship
between the fields of the tables. Keys play a major role when JOINs are used.
Q 3. What are the types of joining and explain each? (ADOBE)
There are various types of join that can be used to retrieve data and it depends on the
relationship between tables.
● Inner Join.
Inner join returns rows when there is at least one match of rows between the tables.
● Right Join.
Right join returns rows that are common between the tables and all rows of the
Right-hand side table. Simply, it returns all the rows from the right-hand side table even
though there are no matches in the left-hand side table.
● Left Join.
Left join returns rows that are common between the tables and all rows of the
Left-hand side table. Simply, it returns all the rows from the Left-hand side table even
though there are no matches in the Right-hand side table.
Q 4. What is the difference between cross join and natural join? (SIEMENS)
The cross join produces the cross product or Cartesian product of two tables whereas
the natural join is based on all the columns having the same name and data types in
both the tables.
Q 5. What is Self-Join? (DELOITTE)
Self-join is set to be a query used to compare to itself. This is used to compare values in
a column with other values in the same column in the same table. ALIAS ES can be used
for the same table comparison.
Q 6. What is the difference between cross join and natural join? (INFOSYS)
The cross join produces the cross product or Cartesian product of two tables whereas
the natural join is based on all the columns having the same name and data types in
both the tables.

More Related Content

Similar to SQL dabatase interveiw pdf for interveiw preparation

PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Trainingbixxman
 
Sql Interview Questions
Sql Interview QuestionsSql Interview Questions
Sql Interview Questionsarjundwh
 
153680 sqlinterview
153680  sqlinterview153680  sqlinterview
153680 sqlinterviewzdsgsgdf
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Rakibul Hasan Pranto
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1sagaroceanic11
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDev Chauhan
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-bookVipul Wankar
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-bookVipul Wankar
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESNathRam2
 

Similar to SQL dabatase interveiw pdf for interveiw preparation (20)

SQL
SQLSQL
SQL
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 
Sql
SqlSql
Sql
 
Sql Interview Questions
Sql Interview QuestionsSql Interview Questions
Sql Interview Questions
 
Sql
SqlSql
Sql
 
Sql
SqlSql
Sql
 
153680 sqlinterview
153680  sqlinterview153680  sqlinterview
153680 sqlinterview
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
Sql overview-1232931296681161-1
Sql overview-1232931296681161-1Sql overview-1232931296681161-1
Sql overview-1232931296681161-1
 
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQLDATABASE MANAGMENT SYSTEM (DBMS) AND SQL
DATABASE MANAGMENT SYSTEM (DBMS) AND SQL
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-book
 
Sql interview-book
Sql interview-bookSql interview-book
Sql interview-book
 
Viva voce
Viva voceViva voce
Viva voce
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 
DATABASE-1.pptx
DATABASE-1.pptxDATABASE-1.pptx
DATABASE-1.pptx
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
Fg d
Fg dFg d
Fg d
 
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLESDATABASE CONCEPTS AND PRACTICAL EXAMPLES
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
 

Recently uploaded

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

SQL dabatase interveiw pdf for interveiw preparation

  • 1. Interview Questions Q 1. What is SQL? (TCS) SQL stands for Structured Query Language. It is the standard language for relational database management systems. It is especially useful in handling organized data composed of entities (variables) and relations between different entities of the data. Q 2. What are the different commands in SQL? (Myntra) ● Data Definition Language (DDL) – It allows you to perform various operations on the database such as CREATE, ALTER, and DELETE objects. ● Data Manipulation Language(DML) – It allows you to access and manipulate data. It helps you to insert, update, delete and retrieve data from the database. ● Data Control Language(DCL) – It allows you to control access to the database. Example – Grant, Revoke access permissions. ● Transaction control Language(TCL) Example - Rollback ,commit Q 3. What are different types of DBMS? (Amazon) There are two types of DBMS: ● Relational Database Management System: The data is stored in relations (tables). Example – MySQL. ● Non-Relational Database Management System: There is no concept of relations, tuples and attributes. Example – MongoDB Q 4. What do you mean by table and field in SQL? (IBM) A table refers to a collection of data in an organised manner in the form of rows and columns. A field refers to the number of columns in a table.
  • 2. Interview Questions Q 1. How to change a table name in SQL? (Vmware) This is the command to change a table name in SQL: ALTER TABLE table_name RENAME TO new_table_name; Q 2. What is the difference between DELETE and TRUNCATE statements? (Goldman Sachs) DELETE TRUNCATE Delete command is used to delete a row in a table. Truncate is used to delete all the rows from a table. You can rollback data after using the delete statement. You cannot rollback data. It is a DML command. It is a DDL command. It is slower than a truncated statement. It is faster. Q 3. What is an Index? (Morgan Stanely) An index refers to a performance tuning method of allowing faster retrieval of records from the table. An index creates an entry for each value and hence it will be faster to retrieve data. Q 4. Explain different types of indexes in SQL. (Microsoft) There are three types of index namely: Unique Index: This index does not allow the field to have duplicate values if the column is uniquely indexed. If a primary key is defined, a unique index can be applied automatically. Clustered Index:
  • 3. 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: 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 nonclustered indexes. Q 5. Are NULL values the same as that of zero or a blank space? (VERITAS, TCS) A NULL value is not at all the 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 Q 6. What are the different types of a subquery? (D.E.SHAW) There are two types of subquery namely, Correlated and Non-Correlated. 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 to the column in a table. Non-Correlated subquery: This query is an independent query where the output of the subquery is substituted in the main query. Q 7. Write a SQL query to find the names of employees that begin with ‘A’? (ADOBE) To display name of the employees that begin with ‘A’, type in the below command: SELECT * FROM Table_name WHERE EmpName like 'A%'; Q 8. What is the need for group functions in SQL? (WIPRO) Group functions work on the set of rows and return one result per group. Some of the commonly used group functions are: AVG, COUNT, MAX, MIN, SUM, VARIANCE. Q 9. How can you insert NULL values in a column while inserting the data? (INTUIT) NULL values in SQL can be inserted in the following ways: ● Implicitly by omitting column from column list. ● Explicitly by specifying NULL keyword in the VALUES clause Q 10. What is the main difference between ‘BETWEEN’ and ‘IN’ condition operators? (GOOGLE)
  • 4. BETWEEN operator is used to display rows based on a range of values in a row whereas the IN condition operator is used to check for values contained in a specific set of values. Q 11. What is the difference between ‘HAVING’ CLAUSE and a ‘WHERE’ CLAUSE? (HSBC) HAVING clause can be used only with a SELECT statement. It is usually used in a GROUP BY clause and whenever GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is only used with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are a part of the GROUP BY function in a query. Q 12. How can you select unique records from a table? (WALMART) You can select unique records from a table by using the DISTINCT keyword. Select DISTINCT studentID from Student Using this command, it will print a unique student id from the table Student. Q 13. Write a Query to display the number of employees working in each region? (MASTERCARD) SELECT region, COUNT(gender) FROM employee GROUP BY region; Q 14. How to use LIKE in SQL? (BITWISE) The LIKE operator checks if an attribute value matches a given string pattern. Here is an example of LIKE operator SELECT * FROM employees WHERE first_name like ‘Steven’; With this command, we will be able to extract all the records where the first name is like “Steven”.
  • 5. Interview Questions Q 1. What is a Primary key? (L&T) ● A Primary key is a column (or collection of columns) or a set of columns that uniquely identifies each row in the table. ● Uniquely identifies a single row in the table ● Null values not allowed Q 2. What is a Unique key? (Persistent) ● Uniquely identifies a single row in the table. ● Multiple values allowed per table. ● Null values allowed. Q 3. What is a Foreign key in SQL? (Mastercard) ● 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. Q 4. What is a View? (BAJAJ ) A view is a virtual table that consists of a subset of data contained in a table. Since views are not present, it takes less space to store. Views can have data of one or more tables combined and it depends on the relationship. Q 5. What are Views used for? (AMAZON) 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 the same data.
  • 6. Interview Questions Q 1.If we drop a table, does it also drop related objects like constraints, indexes, columns, default, views and stored procedures? (ZS) Yes, SQL Server drops all related objects, which exist inside a table like constraints, indexes, columns, defaults etc. But dropping a table will not drop views and stored procedures as they exist outside the table. Q 2. What is a join? (MICROSOFT) This is a keyword used to query data from more tables based on the relationship between the fields of the tables. Keys play a major role when JOINs are used. Q 3. What are the types of joining and explain each? (ADOBE) There are various types of join that can be used to retrieve data and it depends on the relationship between tables. ● Inner Join. Inner join returns rows when there is at least one match of rows between the tables. ● Right Join. Right join returns rows that are common between the tables and all rows of the Right-hand side table. Simply, it returns all the rows from the right-hand side table even though there are no matches in the left-hand side table. ● Left Join. Left join returns rows that are common between the tables and all rows of the Left-hand side table. Simply, it returns all the rows from the Left-hand side table even though there are no matches in the Right-hand side table. Q 4. What is the difference between cross join and natural join? (SIEMENS) The cross join produces the cross product or Cartesian product of two tables whereas the natural join is based on all the columns having the same name and data types in both the tables.
  • 7. Q 5. What is Self-Join? (DELOITTE) Self-join is set to be a query used to compare to itself. This is used to compare values in a column with other values in the same column in the same table. ALIAS ES can be used for the same table comparison. Q 6. What is the difference between cross join and natural join? (INFOSYS) The cross join produces the cross product or Cartesian product of two tables whereas the natural join is based on all the columns having the same name and data types in both the tables.