SQL & My SQL Tutorial
- What is SQL?
- SQL Microsoft
- SQL Management Tools
- SQL Developer
- Docker Commands
- Composite Key in SQL
- SQL Constraints
- Transactions in SQL Server
- SQL Server Data Types
- SQL Update Join
- SQL Operators
- SQL Clauses
- SQL Commands
- SQL Alter Command
- Distinct Keyword in SQL
- SQL Statements
- SQL Index
- SQL Injections
- Wildcards in SQL
- Alter and Truncate Command in SQL
- SQL Null Functions – ISNULL, IFNULL, Combine, & NULLIF
- SQL Sequence
- How to Find Duplicate Records in SQL
- Primary and Foreign Key in SQL with Examples
- COUNT Function
- SUM Function in SQL
- Dynamic SQL
- Database Tuning
- Pseudocolumn in Oracle SQL
- Triggers in SQL
- Embedded SQL in DBMS
SQL or popularly known as Structured Query Language, is the fundamental query language for databases and is a domain-specific language for Relational Database Management Systems. It is useful when the data type is structured and there exists a dependency among the various attributes of data. It is widely used and is one of the most popular query languages for its unique capability of fetching multiple records by just making use of a single query statement. It consists of both DDL (Data Definition Language) and DML(Data Manipulation Language) commands which makes the use of queries much more efficient. SQL is a declarative programming language that is set-based and is therefore not an imperative programming language such as C or BASIC, etc. In order to fetch the data results from the database, you need to know SQL commands which we are going to study in this SQL Tutorial.
Basic SQL Commands
The basic commands are given below.
This is possibly the most basic SQL command. The select command is used to fetch or retrieve results from a particular table of a database. This is generally followed by specific column names or all column names (by making use of * ).
This is one of the basic DDL commands which is used to create a table inside a database. The prerequisites of creating a table include knowing column name and their datatypes.
This DML command is used to make alterations to the table. It includes modifying the table as per the need.
The WHERE clause is one of the most important SQL commands as it is used to retrieve or fetch the specific data that is required for a particular case. This is helpful as it excludes all the irrelevant data.
The ALIAS is among the most common SQL command which is used to give a meaningful name to your attribute or a column. They are defined for columns and tables, which helps in increasing the readability of the query.
This is an SQL operator which is used to combine two conditions. For the row to appear in the data result set, both the conditions should be true.
This is an aggregate function that is used to return the average value of a particular numeric column.
This is used along with the select statement to sort the results either in ascending order or descending order. If no argument is given after the ORDER BY clause, it by default takes as the ascending order query.
The GROUP BY clause in the SQL commands is used to retrieve the data on the basis of some particular grouping related to one or more columns.
The INSERT command is used to add a new row of data inside the table. The mandate for the INSERT command is that the table should be already created.
The intermediate commands are given below:
This command is used to update or modify the existing rows in a table.
As the name suggests, this command is used to delete the rows from a table.
The HAVING clause is used to filter the data based on one or more group functions. This is quite very similar to using a WHERE clause but this includes the use by a group function.
This operator is used to compare between the two conditions and lists down all the rows of a table whose column name matches the pattern specified with the LIKE clause. Wildcard operators such as % are used when you are not sure about the particular pattern.
The IN operator when the comparison of a column is made with multiple values. It is more or less similar to the OR condition.
The IS NULL operator is another SQL-based operator which is used to display whether the particular column name has a NULL value. It is used to fetch all the rows for the specified columns for which the data has not been found or has been found as null.
As the name suggests, this operator filters the results for a particular set of ranges. The value, in this case, can either be numbers, dates or text.
This case is the same as used in other programming languages such as Java, etc., where a decision control statement is taken by the case statement and the argument inside it is used to fetch the case results matching the particular condition.
This is one of the most useful SQL commands which is used to display the count of the total number of rows for all those non-null data. It makes use of the column name as the argument.
This is one of the most important SQL commands which comes into play when there has to build a relationship among the attributes of two tables based on a fixed common attribute. In other words, the join condition has to be true in order for INNER JOIN to function.
Advanced SQL Commands
The advanced commands are given below:
The LIMIT clause will help you specify the maximum number of rows that are allowed in the result set.
This is the join function that comes into play when all the fields of both tables are required based on some common input column condition. If the join condition is not met, then a NULL value will be filled on the right side of the column.