YouTube Icon

Interview Questions.

Top 100+ Sql Interview Questions And Answers - Jun 02, 2020

fluid

Top 100+ Sql Interview Questions And Answers

Question 1. Explain What Is A Database?

Answer :

A database is a set of records in an organized form for quicker and better get admission to, storage and manipulation. It can also be defined as a group of tables, schema, views and other database items.

Question 2. Explain What Is Dbms?

Answer :

Database Management System is a group of packages that permits a person to shop, retrieve, replace and delete information from a database.

SQL Server 2000 Interview Questions
Question three. Explain What Is Rdbms?

Answer :

RDBMS stands for Relational Database Management System. RDBMS is a database control device (DBMS) this is based on the relational version. Data from relational database can be accessed the usage of Structured Query Language (SQL)

Question four. What Are The Popular Database Management Systems In The It Industry?

Answer :

Oracle, MySQL, Microsoft SQL Server, PostgreSQL, Sybase, MongoDB, DB2, and Microsoft Access and so on.,

T-SQL Tutorial
Question five. Explain What Is Sql?

Answer :

SQL stands for Structured Query Language. It is an American National Standard Institute (ANSI) widespread. It is a fashionable language for gaining access to and manipulating databases. Using SQL, a number of the motion we should do are to create databases, tables, saved tactics (SP’s), execute queries, retrieve, insert, replace, delete statistics against a database.

PL/SQL Interview Questions
Question 6. Explain What Is Table In A Database?

Answer :

A desk is a database item used to keep facts in a field in the shape of columns and rows that holds facts.

Question 7. Explain What Is A Field In A Database And Record In A Database?

Answer :

A subject in a Database desk is a area allocated to save a particular document within a table.
A record (also called a row of information) is an ordered set of related facts in a table.
SQL Server 2008 Tutorial T-SQL Interview Questions
Question 8. What Is The Use Of Nvl Function?

Answer :

NVL function is used to convert the null price to its real fee.

Question nine. Explain What Is A Column In A Table?

Answer :

A column is a vertical entity in a table that consists of all facts associated with a specific field in a table.

SQL Server 2008 Interview Questions
Question 10. What Are The Different Types Of Sql Commands?

Answer :

SQL commands are segregated into following sorts:

DDL – Data Definition Language
DML – Data Manipulation Language
DQL – Data Query Language
DCL – Data Control Language
TCL – Transaction Control Language
SQL Database Tutorial
Question 11. What Are The Different Ddl Commands In Sql?

Answer :

DDL commands are used to outline or modify the structure of the database.

CREATE: To create databases and database items

ALTER: To adjust current database items

DROP: To drop databases and databases gadgets

TRUNCATE: To eliminate all facts from a table however not its database structure

RENAME: To rename database objects

SQL Server 2005 Interview Questions
Question 12. What Are The Different Dml Commands In Sql?

Answer :

DML instructions are used for coping with facts present within the database.

SELECT: To pick precise facts from a database

INSERT: To insert new data into a table

UPDATE: To update present facts

DELETE: To delete present statistics from a desk

SQL Server 2000 Interview Questions
Question thirteen. What Are The Different Dcl Commands In Sql?

Answer :

DCL instructions are used to create roles, furnish permission and manage get right of entry to to the database items.

GRANT: To offer consumer get right of entry to

DENY: To deny permissions to customers

REVOKE: To eliminate user get entry to

MySQL Tutorial
Question 14. What Are The Different Tcl Commands In Sql?

Answer :

TCL instructions are used to manipulate the changes made through DML statements.

COMMIT: To write and save the modifications to the database

ROLLBACK: To repair the database because the ultimate dedicate

Question 15. Explain What Is An Index?

Answer :

An index is used to speed up the performance of queries. It makes faster retrieval of records from the desk. The index can be created on one column or a group of columns.

SQL Database Interview Questions
Question 16. Explain What Is A View?

Answer :

A view is sort of a subset of a desk that is stored logically in a database. A view is a digital desk. It contains rows and columns just like a real table. The fields inside the view are fields from one or greater real tables. Views do not contain data of their own. They are used to restriction get admission to to the database or to cover statistics complexity.

DB2 Using SQL Tutorial
Question 17. Explain What Is A Subquery ?

Answer :

A Subquery is a SQL query inside another question. It is a subset of a Select declaration whose return values are used in filtering the situations of the main query.

MySQL Interview Questions
Question 18. What Is The Difference Between Rename And Alias?

Answer :

‘Rename’ is a permanent call given to a table or column

‘Alias’ is a brief name given to a desk or column.

PL/SQL Interview Questions
Question 19. What Is A Join?

Answer :

Join is a question, which retrieves related columns or rows from more than one tables.

Question 20. What Are The Different Types Of Joins?

Answer :

Types of Joins are as follows:

INNER JOIN: It is likewise called SIMPLE JOIN which returns all rows from BOTH tables when it has as a minimum one column matched

Syntax: SELECT column_name(s) 

FROM table_name1 

INNER JOIN table_name2 

ON column_name 1=column_name 2;

LEFT JOIN (LEFT OUTER JOIN): This join returns all rows from a LEFT desk and its matched rows from a RIGHT desk.

Syntax: SELECT column_name(s)

FROM table_name1

LEFT JOIN table_name2

ON column_name 1=column_name 2;

RIGHT JOIN (RIGHT OUTER JOIN): This joins returns all rows from the RIGHT desk and its matched rows from a LEFT desk.

Syntax: SELECT column_name(s)

FROM table_name1

RIGHT JOIN table_name2

ON column_name1=column_name2;

FULL JOIN (FULL OUTER JOIN): This joins returns all whilst there is a in shape either in the RIGHT table or within the LEFT desk.

Syntax: SELECT column_name(s)

FROM table_name1

FULL OUTER JOIN table_name2

ON column_name1=column_name2;

DB2 Using SQL Interview Questions
Question 21. What Are Sql Constraints?

Answer :

SQL constraints are the set of rules that enforced some limit at the same time as putting, deleting or updating of facts within the databases.

Question 22. What Are The Constraints Available In Sql?

Answer :

Some of the restrictions in SQL are : Primary Key, Foreign Key, Unique Key, SQL Not Null, Default, Check and Index constraint.

Question 23. What Is A Unique Key And Primary Key And Foreign Key?

Answer :

A UNIQUE KEY constraint is used to make sure that there are not any duplication values in the area/column.
A PRIMARY KEY constraint uniquely identifies each record in a database table. All columns taking part in a number one key constraint need to now not contain NULL values.
A FOREIGN KEY is a key used to hyperlink two tables collectively. A FOREIGN KEY in a desk is linked with the PRIMARY KEY of another table.
PHP+MySQL Interview Questions
Question 24. What Is The Difference Between Unique And Primary Key Constraints?

Answer :

There must be handiest one PRIMARY KEY in a desk while there can be any number of UNIQUE Keys.

PRIMARY KEY doesn’t permit NULL values while Unique key lets in NULL values.

T-SQL Interview Questions
Question 25. What Is A Null Value?

Answer :

A subject with a NULL cost is a area with no fee. A NULL fee isn't the same as a zero value or a area that includes areas. A area with a NULL value is one that has been left clean at some point of document advent. Assume, there is a area in a desk is optional and it is possible to insert a report with out including a value to the elective area then the sphere might be saved with a NULL value.

Question 26. What Is Normalization?

Answer :

Normalization is the technique of desk design to limit the data redundancy.

There are extraordinary sorts of Noramalization bureaucracy in SQL:-

First Normal Form (1NF): It eliminates all reproduction columns from the table. Creates table for related records and identifies unique column values
First Normal Form (2NF): Follows 1NF and creates and locations data subsets in an character table and defines courting between tables the use of number one key
Third Normal Form (3NF): Follows 2NF and removes those columns which are not associated thru primary key
Fourth Normal Form (4NF): Follows 3NF and do no longer define multi-valued dependencies. 4NF also known as BCNF
PostgreSQL Interview Questions
Question 27. What Is Stored Procedure?

Answer :

A Stored Procedure is a group of SQL statements that have been created and stored in the database to perform a specific task. The stored manner accepts enter parameters and tactics them and returns a single value along with a range of or textual content value or a end result set (set of rows).

SQL Server 2008 Interview Questions
Question 28. What Is A Trigger?

Answer :

A Trigger is a SQL process that initiates an movement in response to an occasion (Insert, Delete or Update) takes place. When a brand new Employee is delivered to an Employee_Details table, new data may be created inside the relevant tables such as Employee Payroll, Employee Time Sheet etc.,

Question 29. List Out The Acid Properties And Explain?

Answer :

Following are the four houses of ACID. These guarantees that the database transactions are processed reliably.

Atomicity
Consistency
Isolation
Durability
SQL DBA Interview Questions
Question 30. What Is The Difference Between Delete, Truncate And Drop Command?

Answer :

The distinction between the Delete, Truncate and Drop command is:

Delete command is a DML command, it is used to delete rows from a table. It can be rolled back.
Truncate is a DDL command, it's far used to delete all the rows from the table and unfastened the gap containing the desk. It cant be rolled returned.
Drop is a DDL command, it removes the complete information at the side of the table shape(in contrast to truncate command that eliminates best the rows). All the tables’ rows, indexes, and privileges can also be removed.
Question 31. What Is The Difference Between Having And Where Clause?

Answer :

Where clause is used to fetch information from a database that specifies specific standards while a Having clause is used in conjunction with ‘GROUP BY’ to fetch data that meets unique criteria certain by means of the Aggregate capabilities. Where clause cannot be used with Aggregate functions, but the Having clause can.

Question 32. What Are Aggregate Functions In Sql?

Answer :

SQL mixture functions return a single fee, calculated from values in a column.

Some of the aggregate features in SQL are as follows:

AVG() : This feature returns the average cost
COUNT() : This function returns the variety of rows
MAX() : This characteristic returns the largest fee
MIN() : This feature returns the smallest cost
ROUND() : This function rounds a numeric discipline to the quantity of decimals specific
SUM() : This characteristic returns the sum
Question 33. What Are String Functions In Sql?

Answer :

SQL string capabilities are used mostly for string manipulation.

Some of the widely used SQL string capabilities are:

LEN() : It returns the duration of the price in a textual content area
LOWER() : It converts character facts to lower case
UPPER() : It converts individual information to top case
SUBSTRING() : It extracts characters from a textual content discipline
LTRIM() : It is to cast off all whitespace from the start of the string
RTRIM() : It is to dispose of all whitespace at the quit of the string
CONCAT() : Concatenate function combines more than one character strings collectively
REPLACE() :To replace the content material of a string.
SQL Server 2005 Interview Questions
Question 34. Explain The Working Of Sql Privileges?

Answer :

SQL GRANT and REVOKE instructions are used to put into effect privileges in SQL a couple of person environments.  The administrator of the database can furnish or revoke privileges to or from customers of database object like SELECT, INSERT, UPDATE, DELETE, ALL and so forth.

GRANT Command: This command is used offer database get admission to to consumer aside from an administrator.

Syntax: GRANT privilege_name

ON object_name

TO user_name

[WITH GRANT OPTION];

In above syntax WITH GRANT OPTIONS indicates that the user can provide the get entry to to any other person too.

REVOKE Command: This command is used provide database deny or take away get admission to to database gadgets.

Syntax: REVOKE privilege_name

ON object_name

FROM user_name;

Question 35. How Many Types Of Privileges Are Available In Sql?

Answer :

There are two forms of privileges used in SQL, which include

System Privilege: System privileges deal with an item of a particular type and specifies the proper to carry out one or greater moves on it which encompass Admin allows a person to carry out administrative obligations, ALTER ANY INDEX, ALTER ANY CACHE GROUP CREATE/ALTER/DELETE TABLE, CREATE/ALTER/DELETE VIEW and so on.

Object Privilege: This lets in to perform moves on an object or item of another user(s) viz. Table, view, indexes etc. Some of the item privileges are EXECUTE, INSERT, UPDATE, DELETE, SELECT, FLUSH, LOAD, INDEX, REFERENCES etc.

Question 36. What Is Sql Injection?

Answer :

SQL Injection is a sort of database assault approach in which malicious SQL statements are inserted into an access field of database such that after it's miles completed the database is opened for an attacker. This approach is generally used for attacking Data-Driven Applications to have an get right of entry to to sensitive statistics and perform administrative obligations on databases.

SQL Database Interview Questions
Question 37. What Is The Difference Between Clustered And Non-clustered Indexes?

Answer :

One desk can have best one clustered index however more than one nonclustered indexes.
Clustered indexes may be read swiftly instead of non-clustered indexes.
Clustered indexes store records bodily in the table or view and non-clustered indexes do not save information in table because it has separate shape from records row
Question 38. What Is Relationship? How Many Types Of Relationship Are There?

Answer :

The courting can be defined as the connection among more than one tables in the database.

There are 4 kinds of relationships:

One to One Relationship
Many to One Relationship
Many to Many Relationship
One to Many Relationship
Question 39. What Is Collation?

Answer :

Collation is set of regulations that check how the facts is sorted by way of evaluating it. Such as Character data is saved the usage of correct man or woman series at the side of case sensitivity, type, and accent.

Question forty. What Is Database White Box Testing And Black Box Testing?

Answer :

Database White Box Testing involves:

Database Consistency and ACID residences
Database triggers and logical views
Decision Coverage, Condition Coverage, and Statement Coverage
Database Tables, Data Model, and Database Schema
Referential integrity rules
Database Black Box Testing includes:

Data Mapping
Data stored and retrieved
Use of Black Box strategies along with Equivalence Partitioning and Boundary Value Analysis (BVA)
MySQL Interview Questions
Question 41. What Are The Advantages Of Views?

Answer :

Advantages of Views:

Views limit get admission to to the statistics because the view can show selective columns from the table.

Views can be used to make simple queries to retrieve the outcomes of complex queries. For example, views may be used to question records from multiple tables without the user understanding.

Question forty two. What Is Schema?

Answer :

A schema is a collection of database gadgets of a User.

DB2 Using SQL Interview Questions
Question forty three. What Is The Difference Between Sql And Pl/sq.?

Answer :

SQL is a established question language to create and access databases while PL/SQL comes with procedural standards of programming languages.

Question forty four. What Is The Difference Between Sql And Mysql?

Answer :

SQL is a based query language this is used for manipulating and getting access to the relational database, then again, MySQL itself is a relational database that makes use of SQL as the same old database language.

Question 45. What Is Sql Sandbox In Sql Server?

Answer :

SQL Sandbox is the safe location in SQL Server Environment wherein untrusted scripts are performed. There are 3 types of SQL sandbox, which include

Safe Access Sandbox: Here a user can carry out SQL operations such as developing saved strategies, triggers and so forth. However can't have access to the memory and can not create files.

External Access Sandbox: User could have get right of entry to to files while not having a proper to govern the memory allocation.

Unsafe Access Sandbox: This contains untrusted codes where a user can have get entry to to memory.




CFG