SQL Interview Questions
1 .
What is the difference between SQL and MySQL?
SQL is a standard language for retrieving and manipulating structured databases.

MySQL is a relational database management system, like SQL Server, Oracle or IBM DB2, that is used to manage SQL databases.
2 .
What is Data Integrity?
Data Integrity is the assurance of accuracy and consistency of data over its entire life-cycle, and is a critical aspect to the design, implementation and usage of any system which stores, processes, or retrieves data. It also defines integrity constraints to enforce business rules on the data when it is entered into an application or a database.
3 .
What is a Query?
A query is a request for data or information from a database table or combination of tables. A database query can be either a select query or an action query.
SELECT fname, lname 		 /* select query */
FROM myDb.students
WHERE student_id = 1;

UPDATE myDB.students 		 /* action query */
SET fname = 'Free Time', lname = 'Learning'
WHERE student_id = 1;
4 .
What is a Subquery? What are its types?
A subquery is a query within another query, also known as nested query or inner query . It is used to restrict or enhance the data to be queried by the main query, thus restricting or enhancing the output of the main query respectively. For example, here we fetch the contact information for students who have enrolled for the maths subject:

SELECT name, email, mob, address
FROM myDb.contacts
WHERE roll_no IN (
	 SELECT roll_no
	 FROM myDb.students
	 WHERE subject = 'Maths');

There are two types of subquery - Correlated and Non-Correlated.
* A correlated subquery cannot be considered as an independent query, but it can refer the column in a table listed in the FROM of the main query.

* A non-correlated subquery can be considered as an independent query and the output of subquery is substituted in the main query.
5 .
What is the SELECT statement?
SELECT operator in SQL is used to select data from a database. The data returned is stored in a result table, called the result-set.
SELECT * FROM myDB.students;
6 .
What are the types of operators available in SQL?
Operators are the special keywords or special characters reserved for performing particular operations and are used in the SQL queries. There is three type of operators used in SQL:
* Arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), etc.


* Comparison operator: =, !=, <>, <, >, <=, >=, !<, !>
7 .
What is the difference between SQL and PL/SQL?
SQL or Structured Query Language is a language which is used to communicate with a relational database. It provides a way to manipulate and create databases. On the other hand, PL/SQL is a dialect of SQL which is used to enhance the capabilities of SQL. It was developed by Oracle Corporation in the early 90's. It adds procedural features of programming languages in SQL.
In SQL single query is being executed at once whereas in PL/SQL a whole block of code is executed at once.
SQL is like the source of data that we need to display on the other hand PL/SQL provides a platform where the SQL the SQL data will be shown.
SQL statement can be embedded in PL/SQL, but PL/SQL statement cannot be embedded in SQL as SQL do not support any programming language and keywords.
8 .
What is the SQL query to display the current date?
There is a built-in function in SQL called GetDate() which is used to return the current timestamp.
9 .
What is a "TRIGGER" in SQL?
* A trigger allows you to execute a batch of SQL code when an insert, update or delete command is run against a specific table as TRIGGER is said to be the set of actions that are performed whenever commands like insert, update or delete are given through queries.

* The trigger is said to be activated when these commands are given to the system.

* Triggers are the particular type of stored procedures that are defined to execute automatically in place or after data modifications.

* Triggers are generated using CREATE TRIGGER statement.
10 .
What are the set operators in SQL?
SQL queries which contain set operations are called compound queries.
Union, Union All, Intersect or Minus operators are the set operators used in the SQL.