The first step to storing the information electronically using SQL includes creating database. And in this section we will learn how to Create, Select, Drop, and Rename databases with examples. The COALESCE() function returns the first non-null value from a list of values.

There are numerous companies around the globe seeking SQL professionals, and they pay high packages. The average salary of SQL developers is around 40,000–65,000 INR. In this section, we have listed some of the top giant companies that hire SQL experts. Views makes easier for anyone to access the information they need, without getting bogged down in complicated queries. Views also act like a helpful security guard, keeping the most sensitive information in the back room, while still allowing access to what’s needed. The content provided on dbvis.com/thetable, including but not limited to code and examples, is intended for educational and informational purposes only.

INSERT

Below, we’ll list the main integrity constraints with brief descriptions and examples. Tutorials Point is a leading Ed Tech company striving to provide the best learning material on technical and non-technical subjects. As an example, let us try to display all the records from the CUSTOMERS table, where the SALARY starts with 200.

  • Rows in the left table will be returned even if there was no match in the right table.
  • Whether you’re a beginner learning SQL or a seasoned professional, these commands will serve as a handy reference for your database operations.
  • You can also pursue an online SQL course to gain practical expertise in using these commands.

This allows you to specify multiple values in a WHERE clause. The USE statement is used to select the database on which you want to perform operations. When you use this statement, complete information present in the database will be lost. FULL JOIN selects records that have a match in the left or right table. Think of it as the “OR” JOIN compared with the “AND” JOIN (INNER JOIN).

Data Control Language

This will retrieve rows where the employee_id is the same in both instances. The query above performs a CROSS JOIN between the employees and departments tables. In the query above, we’re updating the employee_name column to John Doe and the department column to Marketing in a table called employees. In the query above, value Mary is inserted into the first_name column and value Doe is inserted into the last_name column of a table called customers. The AVG command calculates the average of a column’s numeric values.

Basic SQL commands

The following code has a query, which will DELETE a customer, whose ID is 6. Now, let’s move on to the last section of this article on SQL Commands i.e. the Transaction Control Language Commands. This command is used to withdraw the user’s access privileges given by using the GRANT command.

SQL Tutorial Important Note

The LEFT JOIN command returns all rows from the left table (first table) and the matching rows from the right table (second table). The GROUP BY clause is used to group rows based on the values in a specified column. It is often used with aggregate functions like COUNT, SUM, AVG, etc. Querying data commands are SQL statements used to retrieve data from a database.

Basic SQL commands

The query above uses the INTERSECT operator to find the common first_name and last_name between the customers and employees tables. The result will include rows where both the first name and last name are present in both tables. The query above uses the NULLIF function to check if total_amount is equal to discounted_amount. If they are equal, it returns NULL; otherwise, it returns total_amount. The result is returned with the diff_amount indicating the difference (or NULL) between the total amount and the discounted amount for each order.

HAVING Clause

The IF() function evaluates a condition and returns a value based on the evaluation. The SUM command is used to calculate the sum of all values in a specified column. The TRUNCATE command is used to delete the data inside a table, but not the table itself. In this example, we’re deleting rows from the employees table where the employee_name is John Doe.

Basic SQL commands

You can use the ALTER TABLE statement with ADD/DROP Column command according to your need. If you wish to add a column, then you will use the ADD command, and if you wish to delete a column, then you will use the DROP COLUMN command. When you use this statement, complete information present in the table will be lost.

This operator displays all those records which satisfy any of the conditions separated by OR and give the output TRUE. This operator is used to filter records that rely on more than one condition. This operator displays the records, which basic database queries satisfy all the conditions separated by AND, and give the output TRUE. This statement is used to modify the records already present in the table. This constraint consists of a set of default values for a column when no value is specified.

Basic SQL commands

And in this section, we have listed all the points that one has to learn while learning SQL. SQL joins serve as the weaver’s tool, allowing you to seamlessly merge data from multiple tables based on common threads. Basically, these structure functions is very similar to spreadsheets, which store data in very organized grid format.

Transaction Control Language

It allows you to define what data you want your query to return. DCL commands are used to grant and take back authority from any database user. The WITH clause is also known as common table expression (CTE) and subquery factoring. LIKE is a special operator used with the WHERE clause to search for a specific pattern in a column. IS NULL and IS NOT NULL are operators used with the WHERE clause to test for empty values.

You may also like

Leave a Comment