SQL Interview Questions

Relational Databases continue to be the most extensively used database management systems. Accessing and analyzing the data is the top most need these days and SQL enables you to do just that. There is a high demand among the employers for individuals who possess SQL skills. It is therefore absolutely essential for you to prepare yourself with the frequently asked SQL Interview questions, if you want to land your dream job!

Basic SQL Interview Questions and Answers for Freshers

  • #1.What is SQL?
  • #2.How to create a table in SQL?
  • #3.How to delete a table in SQL?
  • #4.How to change a table name in SQL?
  • #5.How to delete a row in SQL?
  • #6.How to create a database in SQL?
  • #7.What is Normalization in SQL?
  • #8.What is join in SQL?
  • #9.What is SQL server?
  • #10.How to insert date in SQL?
  • What is SQL?

    SQL stands for Structured Query Language. It is the primary language to interact with databases. With the help of SQL, we can extract data from a database, modify this data and also update it whenever there is a requirement. This query language is evergreen and is widely used across industries. For example, if a company has records of all the details of their employees in the database. With the help of SQL, all of this data can be queried to find out valuable insights in a short span of time.

    How to create a table in SQL?

    The command to create a table in sql is extremely simple:

     CREATE TABLE table_name (
    	column1 datatype,
    	column2 datatype,
    	column3 datatype,
       ....
    );
    

    We will start off by giving the keywords, CREATE TABLE, then we will give the name of the table. After that in braces, we will list out all the columns along with their datatypes.

    For example, if we want to create a simple employee table:

    CREATE TABLE employee (
    	name varchar(25),
    	age int,
    	gender varchar(25),
       ....
    );

    How to delete a table in SQL?

    There are two ways to delete a table from sql: DROP and TRUNCATE. The DROP TABLE command is used to completely delete the table from the database. This is the command:

    DROP TABLE table_name;

    The above command will completely delete all the data present in the table along with the table itself.

    But if we want to delete only the data present in the table but not the table itself, then we will use the truncate command:

    DROP TABLE table_name ;

    How to change a table name in SQL?

    This is the command to change a table name in SQL:

    ALTER TABLE table_name

    RENAME TO new_table_name;

    We will start off by giving the keywords ALTER TABLE, then we will follow it up by giving the original name of the table, after that, we will give in the keywords RENAME TO and finally, we will give the new table name.

    For example, if we want to change the “employee” table to “employee_information”, this will be the command:

    ALTER TABLE employee

    RENAME TO employee_information;

    How to delete a row in SQL?

    We will be using the DELETE query to delete existing rows from the table:

    DELETE FROM table_name

    WHERE [condition];

    We will start off by giving the keywords DELETE FROM, then we will give the name of the table, after that we will give the WHERE clause and give the condition on the basis of which we would want to delete a row.

    For example, from the employee table, if we would like to delete all the rows, where the age of the employee is equal to 25, then this will the command:

    DELETE FROM employee

    WHERE [age=25];

    How to create a database in SQL?

    A database is a repository in sql, which can comprise of multiple tables.

    This will be the command to create a database in sql:

    CREATE DATABASE database_name.

    What is Normalization in SQL?

    Normalization is used to decompose a larger, complex table into simple and smaller ones. This helps us in removing all the redundant data.

    Generally, in a table, we will have a lot of redundant information which is not required, so it is better to divide this complex table into multiple smaller tables which contains only unique information.

    SQL Interview questions

    Let’s look at the rules for a table to be in first normal form, second normal form and third normal form:

    First normal form:

    A relation schema is in 1NF, if and only if:

    – All attributes in the relation are atomic(indivisible value)

    -And there are no repeating elements or group of elements.

    Second normal form:

    A relation is said to be in 2NF, if and only if:

    It is in 1st Normal Form.

    No partial dependency exists between non-key attributes and key attributes.

    Third Normal form:

    •A relation R is said to be in 3NF if and only if:

    It is in 2NF.

    No transitive dependency exists between non-key attributes and key attributes through another non-key attribute.

    What is join in SQL?

    Joins are used to combine rows from two or more tables, based on a related column between them.

    Types of Joins:

    INNER JOIN − Returns rows when there is a match in both tables.

    LEFT JOIN − Returns all rows from the left table, even if there are no matches in the right table.

    RIGHT JOIN − Returns all rows from the right table, even if there are no matches in the left table.

    FULL OUTER JOIN − Returns rows when there is a match in one of the tables.

    SELF JOIN − Used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

    CARTESIAN JOIN (CROSS JOIN) − Returns the Cartesian product of the sets of records from the two or more joined tables.

    INNER JOIN:

    The INNER JOIN creates a new result table by combining column values of two tables (table1 and table2) based upon the join-predicate. The query compares each row of table1 with each row of table2 to find all pairs of rows which satisfy the join-predicate.

    SYNTAX :

    SELECT table1.col1, table2.col2,…, table1.coln
    FROM table1
    INNER JOIN table2
    ON table1.commonfield = table2.commonfield;
    

    LEFT JOIN:

    The LEFT JOIN returns all the values from the left table, plus matched values from the right table or NULL in case of no matching join predicate.

    SYNTAX :

    SELECT table1.col1, table2.col2,…, table1.coln
    FROM table1
    LEFT JOIN table2
    ON table1.commonfield = table2.commonfield;
    

    RIGHT JOIN:

    The RIGHT JOIN returns all the values from the right table, plus matched values from the left table or NULL in case of no matching join predicate.

    SYNTAX :

    SELECT table1.col1, table2.col2,…, table1.coln
    FROM table1
    RIGHT JOIN table2
    ON table1.commonfield = table2.commonfield;
    

    FULL OUTER JOIN:

    The FULL OUTER JOIN combines the results of both left and right outer joins. The joined table will contain all records from both the tables and fill in NULLs for missing matches on either side.

    SYNTAX :

    SELECT table1.col1, table2.col2,…, table1.coln
    FROM table1
    Left JOIN table2
    ON table1.commonfield = table2.commonfield;
    Union
    SELECT table1.col1, table2.col2,…, table1.coln
    FROM table1
    Right JOIN table2
    ON table1.commonfield = table2.commonfield;

    SELF JOIN:

    The SELF JOIN joins a table to itself; temporarily renaming at least one table in the SQL statement.

    SYNTAX:

    SELECT a.col1, b.col2,..., a.coln
    FROM table1 a, table1 b
    WHERE a.commonfield = b.commonfield;
    

    What is SQL server?

    To understand what exactly is SQL Server, we need to understand what is DBMS and RDBMS. DBMS stands for Database Management System. When we have a huge database with us, we would need a proper management system which would help us organise this database.  There are 4 types of database management systems:

    • Hierarchical 
    • Network
    • Relational 
    • Object-Oriented.

    Out of these database management systems, SQL Server comes under the category of Relational database management system.  A relational database refers to a database that stores data in a structured format, using rows and columns. This makes it easier to locate and access specific values within the database. It is “relational” because the values within each table are related to each other. The relational structure makes it possible to run queries across multiple tables at once.

    How to insert date in SQL?

    If the RDBMS is MYSQL, this is how we can insert date:

    “INSERT INTO tablename (col_name, col_date) VALUES (‘DATE: Manual Date’, ‘2020-9-10’)”;

    11. What is Primary Key in SQL?

    Primary Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level. 

    Let’s look at the different types of constraints which are present in SQL:

    ConstraintDescription
    NOT NULLEnsures that a column cannot have a NULL value.
    DEFAULTProvides a default value for a column when none is specified.
    UNIQUEEnsures that all the values in a column are different
    PRIMARYUniquely identifies each row/record in a database table
    FOREIGNUniquely identifies a row/record in any another database table
    CHECKThe CHECK constraint ensures that all values in a column satisfy certain    conditions.
    INDEXUsed to create and retrieve data from the database very quickly.

    You can consider Primary Key constraint to be a combination of UNIQUE and NOT NULL constraint. This means that if a column is set as a primary key, then this particular column cannot have any null values present in it and also all the values present in this column must be unique.

    12. How do I view tables in SQL?

    To view tables in SQL, all you need to do is give this command:

    Show tables;

    13. What is pl sql?

    PL SQL stands for Procedural language constructs for Structured Query Language. PL SQL was introduced by Oracle to overcome the limitations of plain sql. So, pl sql adds in procedural language approach to the plain vanilla sql.

    One thing to be noted over here is that pl sql is only for oracle databases. If you don’t have an Oracle database, then you cant work with PL SQL.

    While, with the help of sql, we were able to DDL and DML queries, with the help of PL SQL, we will be able to create functions, triggers and other procedural constructs.

    14. What is MYSQL?

    To understand exactly what is MYSQL, we need to understand what is DBMS and RDBMS. DBMS stands for Database Management System. When we have a huge database with us, we would need a proper management system which would help us organise this database.  There are 4 types of database management systems:

    • Hierarchical 
    • Network
    • Relational 
    • Object – Oriented.

    Out of these database management systems, MYSQL comes under the category of Relational database management system.  A relational database refers to a database that stores data in a structured format, using rows and columns. This makes it easier to locate and access specific values within the database. It is “relational” because the values within each table are related to each other. The relational structure makes it possible to run queries across multiple tables at once.

    15. How can I see all tables in SQL?

    Different database management systems have different queries to see all the tables.

    To see all the tables in MYSQL, we would have to use this query:

    show tables;

    This is how we can see all tables in ORACLE:

    SELECT 
        table_name
    FROM
        User_tables;
    

    This is how we can extract all tables in SQL Server:

    SELECT 
        *
    FROM
        Information_schema.tables;
    

    16. What is ETL in SQL?

    ETL stands for Extract, Transform and Load. It is a three step process, where we would have to start off by extracting the data from sources. Once we collate the data from different sources, what we have is raw data. This raw data has to be transformed into tidy format, which will come in the second phase. Finally, we would have to load this tidy data into tools which would help us to find insights.

    17. How to install SQL?

    SQL stands for Structured Query Language and it is not something you can install. To implement sql queries, you would need a relational database management system. There are different varieties of relational database management systems such as:

    • ORACLE
    • MYSQL
    • SQL Server

    Hence, to implement sql queries, we would need to install any of these Relational Database Management Systems.

    18. What is the update command in SQL?

    The update command comes under the DML(Data Manipulation Langauge) part of sql and is used to update the existing data in the table.

    UPDATE employees

    SET last_name=‘Cohen’

    WHERE employee_id=101;

    With this update command, I am changing the last name of the employee.

    19. How to rename column name in SQL Server?

    When it comes to SQL Server, it is not possible to rename the column with the help of ALTER TABLE command, we would have to use sp_rename.

    20. What are the types of SQL Queries?

    We have four types of SQL Queries:

    • DDL (Data Definition Language): the creation of objects
    • DML (Data Manipulation Language): manipulation of data
    • DCL (Data Control Language): assignment and removal of permissions
    • TCL (Transaction Control Language): saving and restoring changes to a database

    Let’s look at the different commands under DDL:

    CommandDescription
    CREATECreate objects in the database
    ALTERAlters the structure of the database object
    DROPDelete objects from the database
    TRUNCATERemove all records from a table permanently
    COMMENTAdd comments to the data dictionary
    RENAMERename an object

    21.  Write a Query to display the number of employees working in each region? 

    SELECT region, COUNT(gender) FROM employee GROUP BY region;

    22. What are Nested Triggers?

    Triggers may implement DML by using INSERT, UPDATE, and DELETE statements. These triggers that contain DML and find other triggers for data modification are called Nested Triggers.

    23. Write SQL query to fetch employee names having a salary greater than or equal to 20000 and less than or equal 10000.

    By using BETWEEN in the where clause, we can retrieve the Employee Ids of employees with salary >= 20000and <=10000. SELECT FullName FROM EmployeeDetails WHERE EmpId IN (SELECT EmpId FROM EmployeeSalary WHERE Salary BETWEEN 5000 AND 10000)

    24. Given a table Employee having columns empName and empId, what will be the result of the SQL query below? select empName from Employee order by 2 asc;

    “Order by 2” is valid when there are at least 2 columns used in SELECT statement. Here this query will throw error because only one column is used in the SELECT statement. 

    25. What is OLTP?

    OLTP stands for Online Transaction Processing. And is a class of software applications capable of supporting transaction-oriented programs. An essential attribute of an OLTP system is its ability to maintain concurrency. 

    26. 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.

    27. What is OLAP?

    OLAP stands for Online Analytical Processing. And a class of software programs which are characterized by relatively low frequency of online transactions. Queries are often too complex and involve a bunch of aggregations. 

    28. Find the Constraint information from the table?

    There are so many times where user needs to find out the specific constraint information of the table. following queries are useful, SELECT * From User_Constraints; SELECT * FROM User_Cons_Columns;

    29. Can you get the list of employees with same salary? 

    Select distinct e.empid,e.empname,e.salary from employee e, employee e1 where e.salary =e1.salary and e.empid != e1.empid 

    30. What is an alternative for TOP clause in SQL?

    1. ROWCOUNT function 
    2. Set rowcount 3
    3. Select * from employee order by empid desc Set rowcount 0 

    31. Will following statement give error or 0 as output? SELECT AVG (NULL)

    Error. Operand data type NULL is invalid for Avg operator. 

    32. What is the Cartesian product of the table?

    The output of Cross Join is called a Cartesian product. It returns rows combining each row from the first table with each row of the second table. For Example, if we join two tables having 15 and 20 columns the Cartesian product of two tables will be 15×20=300 rows.

    33. What is a schema in SQL?

    Our database comprises of a lot of different entities such as tables, stored procedures, functions, database owners and so on. To make sense of how all these different entities interact, we would need the help of schema. So, you can consider schema to be the logical relationship between all the different entities which are present in the database.

    Once we have a clear understanding of the schema, this helps in a lot of ways:

    • We can decide which user has access to which tables in the database.
    • We can modify or add new relationships between different entities in the database.

    Overall, you can consider a schema to be a blueprint for the database, which will give you the complete picture of how different objects interact with each other and which users have access to different entities.

    34. What is the WHERE clause in SQL?

    The ‘Where’ clause is used to extract elements from the table on the basis of a condition.

    Let’s say, we have a table like this:

    Now, if you want to extract all the records “where” the value of “Sepal.Length” is greater than 6, then you can use a query like this:

    1. select * from iris where Sepal.Length>6 

    As, you see, we have extracted all the records, where the value of ‘Sepal.Length’ is greater than 6.

    Similarly, if you want to extract all records where ‘Species’ is Virginia, this will be the query:

    2. select * from iris where Species=’virginica’ 

    35. How to delete a column in SQL?

    To delete a column in SQL we will be using DROP COLUMN method:

    ALTER TABLE employees

    DROP COLUMN age;

    We will start off by giving the keywords ALTER TABLE, then we will give the name of the table, following which we will give the keywords DROP COLUMN and finally give the name of the column which we would want to remove.

    36. What is a unique key in SQL?

    Unique Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level. 

    Unique Key: 

    Whenever we give the constraint of unique key to a column, this would mean that the column cannot have any duplicate values present in it. In other words, all the records which are present in this column have to be unique.

    37. How to implement multiple conditions using WHERE clause?

    We can implement multiple conditions using AND, OR operators:

    SELECT * FROM employees WHERE first_name = ‘Steven’ AND salary <=10000;

    In the above command, we are giving two conditions. The condition ensures that we extract only those records where the first name of the employee is ‘Steven’ and the second condition ensures that the salary of the employee is less than $10,000. In other words, we are extracting only those records, where the employee’s first name is ‘Steven’ and this person’s salary should be less than $10,000.

    You can refer this SQL beginner’s tutorial if you want to know more about Structure Query Language

    SQL Interview Questions for Experienced Professionals

    1. What is SQL injection?

    SQL injection is a hacking technique which is widely used by black-hat hackers to steal data from your tables or databases. Let’s say, if you go to a website and give in your user information and password, the hacker would add some malicious code over there such that, he can get the user information and password directly from the database. If your database contains any vital information, it is always better to keep it secure from SQL injection attacks.

    2. What is a trigger in SQL?

    A trigger is a stored program in a database which automatically gives responses to an event of DML operations done by insert, update, or delete. In other words, is nothing but an auditor of events happening across all database tables.

    Let’s look at an example of a trigger:

    CREATE TRIGGER bank_trans_hv_alert
    	BEFORE UPDATE ON bank_account_transaction
    	FOR EACH ROW
    	begin
    	if( abs(:new.transaction_amount)>999999)THEN
        RAISE_APPLICATION_ERROR(-20000, 'Account transaction exceeding the daily deposit on SAVINGS account.');
    	end if;
    	end;
    
    
    

    3. How to insert multiple rows in SQL?

    To insert multiple rows in SQL we can follow the below syntax:

    INSERT INTO table_name (column1, column2,column3...)
    VALUES
        (value1, value2, value3…..),
        (value1, value2, value3….),
        ...
        (value1, value2, value3);
    

    We start off by giving the keywords INSERT INTO then we give the name of the table into which we would want to insert the values. We will follow it up with the list of the columns, for which we would have to add the values. Then we will give in the VALUES keyword and finally, we will give the list of values.

    Here is an example of the same:

    INSERT INTO employees (
        name,
        age,
        salary)
    VALUES
        (
            'Sam',
            21,
           75000
        ),
        (
            ' 'Matt',
            32,
           85000    ),
    
        (
            'Bob',
            26,
           90000
        );
    

    In the above example, we are inserting multiple records into the table called employees.

    4. How to find the nth highest salary in SQL?

    This is how we can find the nth highest salary in SQL SERVER using TOP keyword:

    SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM #Employee ORDER BY salary DESC ) AS temp ORDER BY salary

    This is how we can find the nth highest salary in MYSQL using LIMIT keyword:

    SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1

    5. How to copy table in SQL?

    We can use the SELECT INTO statement to copy data from one table to another. Either we can copy all the data or only some specific columns.

    This is how we can copy all the columns into a new table:

    SELECT *
    INTO newtable
    FROM oldtable
    WHERE condition;

    If we want to copy only some specific columns, we can do it this way:

    SELECT column1, column2, column3, ...
    INTO newtable 
    FROM oldtable
    WHERE condition;
    

    6. How to add a new column in SQL?

    We can add a new column in SQL with the help of alter command:

    ALTER TABLE employees ADD COLUMN contact INT(10);

    This command helps us to add a new column named as contact in the employees table.

    7. How to use LIKE in SQL?

    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”.

    8. If we drop a table, does it also drop related objects like constraints, indexes, columns, default, views and sorted procedures?

    Yes, SQL server drops all related objects, which exists inside a table like constraints, indexex, columns, defaults etc. But dropping a table will not drop views and sorted procedures as they exist outside the table. 

    9. Can we disable a trigger? If yes, How?

    Yes, we can disable a single trigger on the database by using “DISABLE TRIGGER triggerName ON<> We also have an option to disable all the trigger by using, “DISABLE Trigger ALL ON ALL SERVER”

    10. What is a Live Lock?

    A live lock is one where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keep interferring. A live lock also occurs when read transactions create a table or page. 

    11. How to fetch alternate records from a table?

    Records can be fetched for both Odd and Even row numbers- To display even numbers-. Select employeeId from (Select rowno, employeeId from employee) where mod(rowno,2)=0 To display odd numbers-. Select employeeId from (Select rowno, employeeId from employee) where mod(rowno,2)=1

    12. Define COMMIT and give an example?

    When a COMMIT is uded in a transaction all chnages made in the transaction are written into the database permanently. Example: BEGIN TRANSACTION; DELETE FROM HR.JobCandidate WHERE JobCandidateID = 20; COMMIT TRANSACTION; The above example deletes a job candidate in a SQL server.

    13. Can you join table by itself? 

    A table can be joined to itself using self join, when you want to create a result set that joins records in a table with other records in the same table.

    14. Explain Equi join with example

    When two or more tables has been joined using equal to operator then this category is called as equi join. Just we need to concentrate on condition is equal to(=) between the columns in the table. Example: Select a.Employee_name,b.Department_name from Employee a,Employee b where a.Department_ID=b.Department_ID

    15. How do we avoid getting duplicate entries in a query?

    The SELECT DISTINCT is used to get distinct data from tables using a query. The below SQL query selects only the DISTINCT values from the “Country” column in the “Customers” table: SELECT DISTINCT Country FROM Customers;

    16. How can you create an empty table from an existing table?

    Lets take an example: Select * into studentcopy from student where 1=2 Here, we are copying student table to another table with the same structure with no rows copied.

    17. Write a Query to display odd records from student table?

    SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY student_no) AS RowID FROM student) WHERE row_id %2!=0

    18. Explain Non Equi Join with example?

    1. When two or more tables are joining without equal to condition then that join is known as Non Equi Join. Any operator can be used here that is <>,!=,<,>,Between. Example: Select b.Department_ID,b.Department_name from Employee a,Department b where a.Department_id <> b.Department_ID;

    19. How can you delete duplicate records in a table with no primary key?

    By using the SET ROWCOUNT command. It limits the number of records affected by a command. Let’s take an example, if you have 2 duplicate rows, you would SET ROWCOUNT 1, execute DELETE command and then SET ROWCOUNT 0

    20. Difference between NVL and NVL2 functions?

    Both the NVL(exp1, exp2) and NVL2(exp1, exp2, exp3) functions check the value exp1 to see if it is null. With the NVL(exp1, exp2) function, if exp1 is not null, then the value of exp1 is returned; otherwise, the value of exp2 is returned, but case to the same data type as that of exp1. With the NVL2(exp1, exp2, exp3) function, if exp1 is not null, then exp2 is returned; otherwise, the value of exp3 is returned.

    21. What is the difference between clustered and non-clustered indexes?

    1. Clustered indexes can be read rapidly rather than non-clustered indexes. 

    2. Clustered indexes store data physically in the table or view whereas, non-clustered indexes do not store data in the table as it has separate structure from the data row.

    22. What does this query says? GRANT privilege_name ON object_name TO {user_name|PUBLIC|role_name} [WITH GRANT OPTION];

    The given syntax indicates that the user can grant access to another user too.

    23. Where MyISAM table is stored?

    Each MyISAM table is stored on disk in three files. 

    1. The “.frm” file stores the table definition. 

    2. The data file has a ‘.MYD’ (MYData) extension. 

    3. The index file has a ‘.MYI’ (MYIndex) extension. 

    24. What does myisamchk do?

    It compresses the MyISAM tables, which reduces their disk or memory usage.

    25. What is ISAM?

    ISAM is abbreviated as Indexed Sequential Access Method. It was developed by IBM to store and retrieve data on secondary storage systems like tapes.

    26. What is Database White box testing?

    White box testing includes: Database Consistency and ACID properties Database triggers and logical views Decision Coverage, Condition Coverage, and Statement Coverage Database Tables, Data Model, and Database Schema Referential integrity rules.

    27. What are the different types of SQL sandbox?

    There are 3 different types of SQL sandbox: 

    1. Safe Access Sandbox: Here a user can perform SQL operations such as creating stored procedures, triggers etc. but cannot have access to the memory as well as cannot create files.

     2. External Access Sandbox: Users can access files without having the right to manipulate the memory allocation.

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

    28. What is Database Black Box Testing?

    This testing involves 1. Data Mapping 2. Data stored and retrieved 3. Use of Black Box testing techniques such as Equivalence Partitioning and Boundary Value Analysis (BVA).

    29. Explain Right Outer Join with Example?

    This join is usable, when user wants all the records from Right table (Second table) and only equal or matching records from First or left table. The unmatched records are considered as null records. Example: Select t1.col1,t2.col2….t ‘n’col ‘n.’. from table1 t1,table2 t2 where t1.col(+)=t2.col;

    30. What is a Subquery?

    A SubQuery is a SQL query nested into a larger query. Example: SELECT employeeID, firstName, lastName FROM employees WHERE departmentID IN (SELECT departmentID FROM departments WHERE locationID = 2000) ORDER BY firstName, lastName; 

    SQL Interview Questions for Developers

    1. How to find duplicate records in SQL?

    There are multiple ways to find duplicate records in SQL. Let’s see how can we find duplicate records using groupby:

    SELECT 
        x, 
        y, 
        COUNT(*) occurrences
    FROM z1
    GROUP BY
        x, 
        y
    HAVING 
        COUNT(*) > 1;
    
    

    We can also find duplicates in the table using rank:

    SELECT * FROM ( SELECT eid, ename, eage, Row_Number() OVER(PARTITION BY ename, eage ORDER By ename) AS Rank FROM employees ) AS X WHERE Rank>1
    

    2. What is Case WHEN in SQL?

    If you have knowledge about other programming languages, then you’d have learnt about if-else statements. You can consider Case WHEN to be analogous to that.

    In Case WHEN, there will be multiple conditions and we will choose something on the basis of these conditions.

    Here is the syntax for CASE WHEN:

    CASE
        WHEN condition1 THEN result1
        WHEN condition2 THEN result2
        WHEN conditionN THEN resultN
        ELSE result
    END;

    We start off by giving the CASE keyword, then we follow it up by giving multiple WHEN, THEN statements.

    3. How to find 2nd highest salary in SQL?

    Below is the syntax to find 2nd highest salary in SQL:

    SELECT name, MAX(salary)
      FROM employees
     WHERE salary < (SELECT MAX(salary)
                     FROM employees);
    

    4. How to delete duplicate rows in SQL

    There are multiple ways to delete duplicate records in SQL.

    Below is the code to delete duplicate records using rank:

    alter table emp add  sid int identity(1,1)
    
        delete e
        from  emp e
        inner join
        (select *,
        RANK() OVER ( PARTITION BY eid,ename ORDER BY id DESC )rank
        From emp )T on e.sid=t.sid
        where e.Rank>1
    
        alter table emp 
        drop  column sno

    Below is the syntax to delete duplicate records using groupby and min:

    alter table emp add  sno int identity(1,1)
    	
    	    delete E from emp E
    	    left join
    	    (select min(sno) sno From emp group by empid,ename ) T on E.sno=T.sno
    	    where T.sno is null
    
    	    alter table emp 
    	    drop  column sno	

    5. What is cursor in SQL?

    Cursors in SQL are used to store database tables. There are two types of cursors:

    • Implicit Cursor
    • Explicit Cursor

    Implicit Cursor:

    These implicit cursors are default cursors which are automatically created. A user cannot create an implicit cursor.

    Explicit Cursor:

    Explicit cursors are user-defined cursors. This is the syntax to create explicit cursor:

    DECLARE cursor_name CURSOR FOR SELECT * FROM table_name

    We start off by giving by keyword DECLARE, then we give the name of the cursor, after that we give the keywords CURSOR FOR SELECT * FROM, finally, we give in the name of the table.

    6. How to create a stored procedure using SQL Server?

    If you have worked with other languages, then you would know about the concept of Functions. You can consider stored procedures in SQL to be analogous to functions in other languages. This means that we can store a SQL statement as a stored procedure and this stored procedure can be invoked whenever we want.

    This is the syntax to create a stored procedure:

    CREATE PROCEDURE procedure_name
    AS
    sql_statement
    GO;
    

    We start off by giving the keywords CREATE PROCEDURE, then we go ahead and give the name of this stored procedure. After that, we give the AS keyword and follow it up with the SQL query, which we want as a stored procedure. Finally, we give the GO keyword.

    Once, we create the stored procedure, we can invoke it this way:

    EXEC procedure_name;

    We will give in the keyword EXEC and then give the name of the stored procedure.

    Let’s look at an example of a stored procedure:

    CREATE PROCEDURE employee_location @location nvarchar(20)
    AS
    SELECT * FROM employees WHERE location = @location
    GO;
    

    In the above command, we are creating a stored procedure which will help us to extract all the employees who belong to a particular location.

    EXEC employee_location @location = 'Boston';

    With this, we are extracting all the employees who belong to Boston.

    7. How to create an index in SQL?

    We can create an index using this command:

    CREATE INDEX index_name
    ON table_name (column1, column2, column3 ...);
    

    We start off by giving the keywords CREATE INDEX and then we will follow it up with the name of the index, after that we will give the ON keyword. Then, we will give the name of the table on which we would want to create this index. Finally, in parenthesis, we will list out all the columns which will have the index. Let’s look at an example:

    CREATE INDEX salary
    ON Employees (Salary);
    

    In the above example, we are creating an index called a salary on top of the ‘Salary’ column of the ‘Employees’ table.

    Now, let’s see how can we create a unique index:

    CREATE UNIQUE INDEX index_name
    ON table_name (column1, column2,column3 ...);
    

    We start off with the keywords CREATE UNIQUE INDEX, then give in the name of the index, after that, we will give the ON keyword and follow it up with the name of the table. Finally, in parenthesis, we will give the list of the columns which on which we would want this unique index.

    8. How to change column data-type in SQL?

    We can change the data-type of the column using the alter table. This will be the command:

    ALTER TABLE table_name
    MODIFY COLUMN column_name datatype;
    

    We start off by giving the keywords ALTER TABLE, then we will give in the name of the table. After that, we will give in the keywords MODIFY COLUMN. Going ahead, we will give in the name of the column for which we would want to change the datatype and finally we will give in the data type to which we would want to change.

    9. What is the difference between SQL and NoSQL databases?

    SQL stands for structured query language and is majorly used to query data from relational databases. When we talk about a SQL database, it will be a relational database. 

    But when it comes to NoSQL database, we will be working with non-relational databases.

    SQL Joins Interview Questions

    1. How to change column name in SQL?

    The command to change the name of a column is different in different RDBMS.

    This is the command to change the name of a column in MYSQL:

    ALTER TABLE Customer CHANGE Address Addr char(50);

    IN MYSQL, we will start off by using the ALTER TABLE keywords, then we will give in the name of the table. After that, we will use the CHANGE keyword and give in the original name of the column, following which we will give the name to which we would want to rename our column.

    This is the command to change the name of a column in ORACLE:

    ALTER TABLE Customer RENAME COLUMN Address TO Addr;

    In ORACLE, we will start off by using the ALTER TABLE keywords, then we will give in the name of the table. After that, we will use the RENAME COLUMN keywords and give in the original name of the column, following which we will give the TO keyword and finally give the name to which we would like to rename our column.

    When it comes to SQL Server, it is not possible to rename the column with the help of ALTER TABLE command, we would have to use sp_rename.

    2. What is a view in SQL?

    A view is a database object that is created using a Select Query with complex logic, so views are said to be a logical representation of the physical data, i.e Views behave like a physical table and users can use them as database objects in any part of SQL queries.

    Let’s look at the types of Views:

    • Simple View
    • Complex View
    • Inline View
    • Materialized View

    Simple View:

    Simple views are created with a select query written using a single table. Below is the command to create a simple view:

    Create VIEW Simple_view as Select * from BANK_CUSTOMER ;

    Complex View:

    Create VIEW Complex_view as SELECT bc.customer_id , ba.bank_account From Bank_customer bc JOIN Bank_Account ba Where bc.customer_id = ba.customer_id And ba.balance > 300000

    Inline View:

    A subquery is also called as an inline view if and only if it is called in FROM clause of a SELECT query.

    SELECT * FROM ( SELECT bc.customer_id , ba.bank_account From Bank_customer bc JOIN Bank_Account ba Where bc.customer_id = ba.customer_id And ba.balance > 300000)

    3. How to drop a column in SQL?

    To drop a column is SQL, we will be using this command:

    ALTER TABLE employees
    DROP COLUMN gender;
    

    We will start off by giving the keywords ALTER TABLE, then we will give the name of the table, following which we will give the keywords DROP COLUMN and finally give the name of the column which we would want to remove.

    4. How to remove duplicate rows in SQL?

    There are a lot of ways to remove duplicate rows in SQL. Let’s look at this example:

    SELECT [Name],
        [Age],
        [Gender],
        COUNT(*) AS CNT
    FROM [mydata].[dbo].[Employees]
    GROUP BY [Name],
          [Age],
          [Gender]
    HAVING COUNT(*) > 1;
    

    In the above command, we are using group by and having to count the duplicate records.

    5. How to join two tables in SQL?

    Joins are used to combine rows from two or more tables, based on a related column between them.

    Types of Joins:

    INNER JOIN − Returns rows when there is a match in both tables.

    LEFT JOIN − Returns all rows from the left table, even if there are no matches in the right table.

    RIGHT JOIN − Returns all rows from the right table, even if there are no matches in the left table.

    FULL OUTER JOIN − Returns rows when there is a match in one of the tables.

    SELF JOIN − Used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

    CARTESIAN JOIN (CROSS JOIN) − Returns the Cartesian product of the sets of records from the two or more joined tables.

    6. How to use BETWEEN in SQL?

    The BETWEEN operator checks an attribute value within a range. Here is an example of BETWEEN operator:

    SELECT * FROM employees WHERE salary between 10000 and 20000;

    With this command, we will be able to extract all the records where the salary of the employee is between 10000 and 20000.

    Advanced SQL Interview Questions

    1. What are the subsets of SQL?

    a. DDL (Data Definition Language): Used to define the data structure it consists of the commands like CREATE, ALTER, DROP, etc. 

    b. DML (Data Manipulation language): Used to manipulate already existing data in the database, commands like SELECT, UPDATE, INSERT 

    c. DCL (Data Control Language): Used to control access to data in the database, commands like GRANT, REVOKE

    2. What is the difference between CHAR and VARCHAR2 datatype in SQL?

    CHAR is used to store fixed-length character strings, and VARCHAR2 used to store variable-length character strings

    3. How to sort a column using a column alias?

    By using the column alias in the ORDER BY instead of where clause for sorting

    4. What is the difference between COALESCE() & ISNULL() ? 

    COALESCE() accepts two or more parameters, one can apply 2 or as many parameters but it returns only the first non NULL parameter. 

    ISNULL() accepts only 2 parameters. 

    The first parameter is checked for a NULL value, if it is NULL then the 2nd parameter is returned, otherwise, it returns the first parameter.

    5. What is “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. 

    6. Write a Query to display employee details along with age?

    SELECT * DATEDIFF(yy, dob, getdate()) AS ‘Age’ FROM employee

    7. Write a Query to display employee details along with age?

    SELECT SUM(salary) FROM employee

    8. Write an SQL query to get the third maximum salary of an employee from a table named employee_table.

    SELECT TOP 1 salary FROM ( SELECT TOP 3 salary FROM employee_table ORDER BY salary DESC ) AS emp ORDER BY salary ASC; 

    9. What are aggregate and scalar functions?

    Aggregate functions are used to evaluate mathematical calculation and return single values. This can be calculated from the columns in a table. Scalar functions return a single value based on input value. 

    Example -. Aggregate – max(), count – Calculated with respect to numeric. Scalar – UCASE(), NOW() – Calculated with respect to strings.

    10. What is a deadlock?

    It is an unwanted situation where two or more transactions are waiting indefinitely for one another to release the locks. 

    11. Explain left outer join with example?

    Left outer join is useful if you want all the records from the left table(first table) and only matching records from 2nd table. The unmatched records are null records. Example: Left outer join with “+” operator Select t1.col1,t2.col2….t ‘n’col ‘n.’. from table1 t1,table2 t2 where t1.col=t2.col(+);

    12. What is SQL injection?

    SQL injection is a code injection technique used to hack data-driven applications

    13. What is an UNION operator?

    The UNION operator combines the results of two or more Select statements by removing duplicate rows. The columns and the data types must be the same in the SELECT statements.

    14. Explain SQL Constraints?

    Constraints are used to specify the rules of data type in a table. They can be specified while creating and altering the table. The following are the constraints in SQL: NOT NULL CHECK DEFAULT UNIQUE PRIMARY KEY FOREIGN KEY

    15. What is ALIAS command?

    This command provides another name to a table or a column. It can be used in WHERE clause of a SQL query using the “as” keyword. 

    16. What are Group Functions? Why do we need them?

    Group functions work on a set of rows and return a single result per group. The popularly used group functions are AVG, MAX, MIN, SUM, VARIANCE, COUNT

    17. How can dynamic SQL be executed?

    • By executing the query with parameters 
    • By using EXEC 
    • By using sp_executesql

    18. What is the usage of NVL() function?

    This function is used to convert NULL value to the other value.

    19. Write a Query to display employee details belongs to ECE department?

    SELECT EmpNo, EmpName, Salary FROM employee WHERE deptNo in (select deptNo from dept where deptName = ‘ECE’)

    20. What are the main differences between #temp tables and @table variables and which one is preferred ?

    1. SQL server can create column statistics on #temp tables. 

    2. Indexes can be created on #temp tables 

    3. @table variables are stored in memory up to a certain threshold

    21. What is CLAUSE

    SQL clause is defined to limit the result set by providing condition to the query. This usually filters some rows from the whole set of records. Example – Query that has WHERE condition

    22. What is recursive stored procedure?

    A stored procedure which calls by itself until it reaches some boundary condition. This recursive function or procedure helps programmers to use the same set of code any number of times.

    23. What is a schema?

    A schema is a collection of database objects in a database for a particular user/owner. Objects can be tables, views, indices and so on.

    24. What does the BCP command do?

    The Bulk Copy is a utility or a tool that exports/imports data from a table into a file and vice versa. 

    25. What is a Cross Join?

    In SQL cross join, a combination of every row from the two tables is included in the result set. This is also called cross product set. For example, if table A has ten rows and table B has 20 rows, the result set will have 10 * 20 = 200 rows provided there is NOWHERE clause in the SQL statement.

    26. Which operator is used in query for pattern matching?

    LIKE operator is used for pattern matching, and it can be used as- 1. % – Matches zero or more characters. 2. _(Underscore) – Matching exactly one character.

    27. Write a SQL query to get the current date?

    SELECT CURDATE();

    28. State the case maniplation functions in SQL?

    1. LOWER: converts all the characters to lowercase.

    2. UPPER: converts all the characters to uppercase. 

    3. INITCAP: converts initial character of each word to uppercase

    29. How to add a column to an existing table?

    ALTER TABLE Department ADD (Gender, M,F)

    30. Define lock escalation?

    A query first takes the lowest level lock possible with the smallest row-level.When too many rows are locked, the lock is escalated to a range or page lock. If too many pages are locked, it may escalate to a table lock. 

    31. How to store Videos inside SQL Server table ?

    By using FILESTREAM datatype, which was introduced in SQL Server 2008.

    32. State the order of SQL SELECT?

    Order of SQL SELECT clauses is: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. Only the SELECT and FROM clauses are mandatory.

    33. What is the difference between IN and EXISTS?

    IN: Works on List result set Doesn’t work on subqueries resulting in Virtual tables with multiple columns Compares every value in the result list.

    Exists: Works on Virtual tables Is used with co-related queries Exits comparison when match is found

    34. How do you copy data from one table to another table ?

    INSERT INTO table2 (column1, column2, column3, …) SELECT column1, column2, column3, … FROM table1 WHERE condition;

    35. List the ACID properties that makes sure that the database transactions are processed

    ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties that guarantee that database transactions are processed reliably. 

    36. What will be the output of the following Query, provided the employee table has 10 records? 

    BEGIN TRAN TRUNCATE TABLE Employees ROLLBACK SELECT * FROM Employees

    This query will return 10 records as TRUNCATE was executed in the transaction. TRUNCATE does not itself keep a log but BEGIN TRANSACTION keeps track of the TRUNCATE command.

    37. What do you mean by Stored Procedures? How do we use it?

    A stored procedure is a collection of SQL statements that can be used as a function to access the database. We can create these stored procedures earlier before using it and can execute them wherever required by applying some conditional logic to it. Stored procedures are also used to reduce network traffic and improve performance.

    38. What does GRANT command do?

    This command is used to provide database access to users other than the administrator in SQL privileges.

    39. What does First normal form do?

    First Normal Form (1NF): It removes all duplicate columns from the table. It creates a table for related data and identifies unique column values.

    40. How to add e record to the table?

    INSERT syntax is used to add a record in the table. INSERT into table_name VALUES (value1, value2..);

    41. What are the different tables present inMySQL?

    There are 5 tables present in MYSQL.

     1. MyISAM 

    2. Heap 

    3. Merge 

    4. INNO DB 

    5. ISAM

    42. What is BLOB and TEXT in MySQL?

    BLOB stands for large binary object. It is used to hold a variable amount of data. TEXT is a case-insensitive BLOB. TEXT values are non-binary strings (character string). 

    43. What is the use of mysql_close()?

    Mysql_close() cannot be used to close the persistent connection. Though it can be used to close connection opened by mysql_connect().

    44. How do you return a hundred books starting from 25th?

    SELECT book_titile FROM books LIMIT 25,100; 

    45. How would you select all the users, whose phone number is NULL?

    SELECT user_name FROM users WHERE ISNULL(user_phonenumber); 

    46. How do you run batch mode in mysql?

    SELECT user_name FROM users WHERE ISNULL(user_phonenumber); 

    47. Write an SQL query to show the second highest salary from a table.

    Select max(Salary) from Worker where Salary not in (Selct max(Salary) from Worker); 

    48.  Write an SQL query to fetch three max salaries from a table.

    SELECT distinct Salary from worker a WHERE 3 >= (SELECT count(distinct Salary) from worker b WHERE a.salary <= b.Salary) order by a.Salary desc;

    49. What is the difference between NOW() and CURRENT_DATE()?

    NOW () command is used to show current year,month,date with hours,minutes and seconds. CURRENT_DATE() shows current year,month and date only.

    50. How can we convert between Unix & MySQL timestamps?

    UNIX_TIMESTAMP is the command which converts from MySQL timestamp to Unix timestamp FROM_UNIXTIME is the command which converts from Unix timestamp to MySQL timestamp.

    51. What are the nonstandard string types?

    Following are Non-Standard string types: 

    1. TINYTEXT 

    2. TEXT 

    3. MEDIUMTEXT 

    4. LONGTEXT

    52. What is the group by clause used for?

    The group by clause combines all those records that have identical values in a particular field or any group of fields.

    53. How do you get the last id without the max function?

    SELECT ID from table order by ID desc limit 1

    54. Write a SQL query to fetch only even rows from the table.

    Using the same Row_Number() and checking that the remainder when divided by 2 is 0- SELECT E.EmpId, E.Project, E.Salary FROM ( SELECT *, Row_Number() OVER(ORDER BY EmpId) AS RowNumber FROM EmployeeSalary ) E WHERE E.RowNumber % 2 = 0

    55. Write a SQL query to create a new table with data and structure copied from another table.

    Using SELECT INTO command- SELECT * INTO newTable FROM EmployeeDetails; 

    56. What are the different types of Collation Sensitivity?

    Case sensitivity: A and a are treated differently. Accent sensitivity: a and á are treated differently. Kana sensitivity: Japanese kana characters Hiragana and Katakana are treated differently. Width sensitivity: Same character represented in single-byte (half-width) and double-byte (full-width) are treated differently.

    57. Write a query to find out the data between range?

    In day to day activities the user needs to find out the data between some range. To achieve this user needs to use Between..and operator or Greater than and less than operator. 

    Query 1 : Using Between..and operator
    Select * from Employee where salary between 25000 and 50000;
    Query 2 : Using operators (Greater than and less than)
    Select * from Employee where salary >= 25000 and salary <= 50000;

    58. How to calculate the number of rows in a table without using the count function?

    There are so many system tables which are very important .Using the system table user can count the number of rows in the table.following query is helpful in that case, Select table_name, num_rows from user_tables where table_name=’Employee’;

    59. What is wrong with the following query? SELECT empName FROM employee WHERE salary <> 6000

    The following query will not fetch a record with the salary of 6000 but also will skip the record with NULL. 

    60. Will the following statements execute? if yes what will be output? SELECT NULL+1 SELECT NULL+’1′

    Yes, no error. The output will be NULL. Perform any operation on NULL will get the NULL result.

    SQL vs. PL/SQL

    BASIS FOR COMPARISONSQLPL/SQL
    BasicIn SQL you can execute a single query or a command at a time.In PL/SQL you can execute a block of code at a time.
    Full formStructured Query LanguageProcedural Language, an extension of SQL.
    PurposeIt is like a source of data that is to be displayed.It is a language that creates an application that display’s data acquired by SQL.
    WritesIn SQL you can write queries and command using DDL, DML statements.In PL/SQL you can write block of code that has procedures, functions, packages or variables, etc.
    UseUsing SQL, you can retrieve, modify, add, delete, or manipulate the data in the database.Using PL/SQL, you can create applications or server pages that display the information obtained from SQL in a proper format.
    EmbedYou can embed SQL statement in PL/SQL.You can not embed PL/SQL in SQL

    SQL having vs where

    S. No.Where ClauseHaving Clause
    1The WHERE clause specifies the criteria which individual records must meet to be selected by a query. It can be used without the GROUP by clauseThe HAVING clause cannot be used without the GROUP BY clause
    2The WHERE clause selects rows before groupingThe HAVING clause selects rows after grouping
    3The WHERE clause cannot contain aggregate functionsThe HAVING clause can contain aggregate functions
    4WHERE clause is used to impose a condition on SELECT statement as well as single row function and is used before GROUP BY clauseHAVING clause is used to impose a condition on GROUP Function and is used after GROUP BY clause in the query
    5SELECT Column,AVG(Column_nmae)FROM Table_name WHERE Column > value GROUP BY Column_nmaeSELECT Columnq, AVG(Coulmn_nmae)FROM Table_name WHERE Column > value GROUP BY Column_nmae Having column_name>or<value

    When to use NoSQL vs SQL

    SQL Databases NoSQL Databases
    Data Storage Model Tables with fixed rows and columns Document: JSON documents, Key-value: key-value pairs, Wide-column: tables with rows and dynamic columns, Graph: nodes and edges
    Development History Developed in the 1970s with a focus on reducing data duplication Developed in the late 2000s with a focus on scaling and allowing for rapid application change driven by agile and DevOps practices.
    Examples Oracle, MySQL, Microsoft SQL Server, and PostgreSQL Document: MongoDB and CouchDB, Key-value: Redis and DynamoDB, Wide-column: Cassandra and HBase, Graph: Neo4j and Amazon Neptune
    Primary Purpose General purpose Document: general purpose, Key-value: large amounts of data with simple lookup queries, Wide-column: large amounts of data with predictable query patterns, Graph: analyzing and traversing relationships between connected data
    Schemas Rigid Flexible
    Scaling Vertical (scale-up with a larger server) Horizontal (scale-out across commodity servers)
    Multi-Record ACID Transactions SupportedMost do not support multi-record ACID transactions. However, some—like MongoDB—do.
    JoinsTypically required Typically not required
    Data to Object MappingRequires ORM (object-relational mapping) Many do not require ORMs. MongoDB documents map directly to data structures in most popular programming languages.

    SQL vs TSQL

    SQLTSQL
    A domain-specific language used in programming and designed for managing data held in a Relational Database Management SystemMicrosoft’s proprietary version of SQL for its SQL Server RDBMS
    Stands for Structured Query LanguageStands for Transact Structured Query Language
    Query Language to Manage Data in an RDBMSAn Extension of SQL That is Used on MS SQL Server
    Developed by IDMDeveloped by Microsoft
    It is Possible to Embed SQL into TSQLIt is Not Possible to Embed TSQL into SQL
    Helps to Process and Analyze the Data Using Simple QueriesHelps to Add Business Logic into an Application

    MySQL vs SQL Server

    SQL ServerMySQL Server
    Relational Database Management SystemOpen-source Relational Database Management System
    Developed by MicrosoftDeveloped by Oracle
    Available in Multiple LanguagesOnly Available in English
    Supports Windows, Linux and ContainersSupports Windows, Linux and Mac
    CommercialOpen-Source
    Programmed in C++Programmed in C and C++
    Compatible with Kubernetes, Apache Spark and Hadoop Distributed File SystemHas Difficulty Operating with Kubernetes, Apache Spark and Hadoop Distributed File System

    MongoDB vs SQL

    MongoDBMySQL
    When you need high availability of data with automatic, fast, and instant data recoveryIf you’re just starting and your database is not going to scale much, MYSQL will help you in easy and low-maintenance setup
    In future, if you’re going to grow big as MongoDB has in-built sharding solutionIf you want high performance on a limited budget
    If you have an unstable schema and you want to reduce your schema migration costIf you have fixed schema and data structure isn’t going to change over time like WikiPedia
    If you don’t have a database administratorIf high transaction rate I going to be your requirement
    If most of the services are cloud-based, MongoDB is best suitable for youIf data security is the topmost priority, MySQL is most suited DBMS

    This brings us to the end of the SQL Interview questions. Glad to see you are now better equipped to face an interview. 

    Wondering where to learn the highly coveted in demand skills for free? Check out the courses on Great Learning Academy. Enroll to any course, learn the in demand skill and get your free certificate. Hurry!

    1

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here

    two × 5 =