What Is SQL Queries? List Of All SQL Queries With Examples

Correspondingly, the column of the left table will have nulls if there are no matching rows for the row in the right table. Some versions of SQL include proprietary extensions to the standard language for procedural programming and other functions. For example, Microsoft offers a set of extensions called Transact-SQL, while Oracle’s extended version of the standard is Procedural Language for SQL. Commercial vendors offer proprietary extensions to differentiate their product offerings by giving customers additional features and functions. As a result, the different variants of extended SQL offered by vendors are not fully compatible with one another. SQL became the de facto standard programming language for relational databases after they emerged in the late 1970s and early 1980s.

Types of SQL queries

DCL (Data Controlling Language) is a query language that allows users to retrieve and edit data held in databases. The types of Data Controlling Language commands include Grant and Revoke. In an era when massive volumes of data are generated, there is a constant need to manage data in databases. SQL is the foundation of relational databases, which are one of the most common databases. As a result, SQL abilities are required in almost every employment role.

SQL Database

A COMMIT statement will release any existing savepoints that may be in use and once the statement is issued, you cannot roll back the transaction. INNER JOIN selects records basis sql that have matching values in both tables. The OFFSET statement works with ORDER BY and specifies the number of rows to skip before starting to return rows from the query.

  • I have already explained different examples and ways to create a table in SQL.
  • This query displays the total number of customers by counting each customer ID.
  • There are many types of indexes such as Bitmap indexes, Partitioned indexes, Function-based indexes, and Domain indexes.
  • CREATE DATABASE creates a new database, assuming the user running the command has the correct admin rights.

IN allows us to specify multiple values we want to select for when using the WHERE command. BETWEEN filters your query to return only results that fit a specified range. SELECT TOP only returns the top x number or percent from a table. Below is a comprehensive list of SQL commands, organized by the top-level of each (e.g. SELECT TOP is within the SELECT category). In our example, we want to join the tables Person.Person and HumanResources.Employee to retrieve a list of all Person LastNames, but also show JobTitle if the Person is an Employee. Given its longevity and importance to so many different applications, learning SQL can be an important career goal.

SQL Commands: Set Operations

This query filters out results that do not match a specified search. This example will add any records from the year 2018 to the archive. The UNION keyword makes it possible to combine JOINS and other criteria to achieve a very powerful new table generation potential. The ordering of the result can also be set manually, using “asc ” for ascending and “desc” for descending. Navy, Central Intelligence Agency, and other U.S. government agencies. In June 1979, Relational Software introduced one of the first commercially available implementations of SQL, Oracle V2 (Version2) for VAX computers.

Types of SQL queries

A DDL statement is either blocking or nonblocking, and both types of DDL statements require exclusive locks on internal structures. Rollback command allows you to undo transactions that have not already been saved to the database. This command is used to save all the transactions to the database. This command is use to give user access privileges to a database. This command is used to update or modify the value of a column in the table.

Database Queries in SQL

I have already explained different examples and ways to create a table in SQL. In the era where data is being generated in humongous amounts, there is a constant need to handle data in databases. Relational databases are one of the most popular databases, and SQL is the basis of relational databases. Therefore SQL skills are indispensable in most of the job roles. In this article on SQL Commands, I will discuss the top commands and statements that you need to understand in SQL.