Category: Advanced SQL

  • Database Tuning

    SQL Database Tuning Database Tuning in SQL is a set of activities performed to optimize a database and prevents it from becoming a bottleneck. There are various techniques with which you can configure the optimal performance of a particular database. Database tuning overlaps with query tuning; so, good indexing and avoiding improper queries help in…

  • IN vs EXISTS

    In SQL, we use the IN operator to simplify queries and reduce the need for multiple OR conditions. It allows us to match a value against a list of values. On the other hand, the EXISTS operator checks whether one or more rows exist in a subquery and returns either true or false based on…

  • Group By vs Order By

    In SQL, we have two commonly used clauses that help us to manipulate data; Group By clause and Order By clause. A Group By clause is used to arrange the identical data/records into groups and the Order By clause is used to sort the data in ascending or descending order. The SQL Group By Clause…

  • Common Table Expression

    A Common Table Expression (CTE) can make it easier to manage and write complex queries by making them more readable and simple, like database views and derived tables. We can reuse or rewrite the query by breaking down the complex queries into simple blocks. The SQL Common Table Expression The WITH clause in MySQL is used to…

  • Cursors

    A database cursor solves the problem of impedance mismatch. It acts as a filter between the result of a SQL query and the statements that process this result. Cursors in SQL A Cursor is a temporary memory that is allocated by the database server at the time of performing the Data Manipulation Language operations on a table, such as INSERT,…

  • Date & Time

    SQL provides multiple datatypes and functions to handle Date and Time values in a database. This is because Date and Time values are represented in various formats. For instance, there are two common ways to represent a date value: DD/MM/YYYY and MM/DD/YYYY. Similarly, there is more than a single way to represent time values. For a database to recognize such…

  • Auto Increment

    The SQL Auto Increment is used to automatically add unique sequential values into a column of a table. We usually define the Auto Increment on a column while creating a table. And when we insert new records into the table, the unique values are added to them. When we use Auto Increment on a table…

  • Using Sequences

    Sequences in SQL are database objects that generate a sequence of unique integer values. They are frequently used in databases because many applications require that each row in a table must contain unique values and sequences provide an easy way to generate them. Sequences are a feature of many SQL database management systems, such as Oracle,…

  • Handling Duplicates

    Sometimes, tables or result sets contain duplicate records. While in most cases, duplicates are allowed, there are situations where it is necessary to prevent duplicate records and remove them from a database table. Why is Handling Duplicates in SQL Necessary? Handling duplicates in an SQL database becomes necessary to prevent the following consequences − This…

  • Sub Queries

    SQL Subqueries An SQL Subquery, is a SELECT query within another query. It is also known as Inner query or Nested query and the query containing it is the outer query. The outer query can contain the SELECT, INSERT, UPDATE, and DELETE statements. We can use the subquery as a column expression, as a condition in SQL clauses, and with…