Structured Query Language, SQL commands, COBOL+DB2, DB2 cursors
SQL — Structured Query language.

What is SQL and why you need SQL?

Topictrick.com
4 min readDec 17, 2020

--

Data is a collection of facts, that computers can understand and process. So, when you book your flight or pay utility bills, or share photographs on the social media platform. Your action generates tons of data.

Different storage mediums such as databases, file systems, etc. store generated data for processing. Large scale enterprise applications generally use the database to store this valuable information.

Proper storage and analysis of data not only improve the process but also boost the profit.

Now, the question is how to store and access data from the database. The answer is SQL or Structured Query Language.

Let’s try to answer two important questions.

  • What is SQL?
  • What is SQL used for?.

An Overview of SQL.

The term SQL stands for “Structured Query Language”. It’s popularly known as “SQL” or “SEQUEL” or “ESS-CUE-EL”.

What is Structured Query Language?
What is SQL?

SQL is a powerful data manipulation tool that is supported by all the leading RDBMS products such as DB2, MS SQL Server, Oracle, MYSQL, etc.

“SQL is the language that communicates with the database.”

The programmer uses SQL statements to specifies what data to be fetched or updated, but does not specifies how to perform the operation. DBMS parse and analyze the SQL statement to find the optimal path to retrieve data from the tables.

Features of SQL.

SQL is not just a query language but it’s the complete package in itself. The structured query language (SQL) provides all most all features of a high-level programming language such as JAVA, COBOL, REXX, C++, etc. In fact, users can easily manipulate data without writing a huge chunk of code. Following are a few salient features of SQL.

  • SQL is simple and easy to use.
  • SQL is flexible and portable.
  • SQL statements are used to retrieve data instead of lengthy code.
  • SQL is a free-form structure.

What is the difference between SQL and Host language?

A high-level programming language such as COBOL, JAVA, REXX, etc. is designed to processing one record-at-a-time. However, SQL is designed to process a set of records at-a-time. In set-level processing, all operations applied on the set and the output is a set of records. But, sometimes the result set can be an empty or single row.

Difference between SQL and host language programming.
Difference between SQL vs Host Language Programming.

Host languages such as COBOL, JAVA, REXX, etc. can not handle many records in a single request. Thus, in the COBOL-DB2 or JAVA-DB2 application, you need a DB2 cursor and host variables to process many records.

Let’s talk about the different types of SQL statements.

What are the different types of SQL statements?

There are no specific criteria for categorizing SQL statements. SQL statements are generally categorized into two categories.

  • SQL Functionality.
  • SQL Execution.

The two categorized further sub-divided into many categories. Let’s look at each of them one by one.

Based on the Functionality the SQL statements are of three types:

  1. Data Control Language (DCL): Control the user access to data. SQL statements such as Grant/Revok are used to grant or revoke user access to the data.
  2. Data Manipulation Language (DML): Maniulupate data stored in the database tables. SQL statements such as Select, Insert, Update, and Delete is used to perform various data manipulation operations.
  3. Data Definition Language (DDL): Create data objects such as tables, views, etc. SQL statements such as Create table, Drop table is used to create database objects.
Type of SQL Statements.

Based on the Execution the SQL statements are of two types:

  1. Static SQL or Embedded SQL statements: These SQL statements are hardcoded into application programs such as COBOL+DB2.
  2. Dynamic SQL statements: These SQL statements are prepared by the application program during the run-time.

SQL Examples:

Following are some SQL statement examples.

  • SELECT EMPNO, FIRSTNAME, LASTNAME FROM DSN90.EMPLOYEE;
  • DELETE FROM DSN90.EMPLOYEE WHERE EMPNO=0010;

What is SQL and why you need SQL?

This SQL tutorial is linked to a youtube video for better understanding. Please do visit and consider subscribing to my channel.

Conclusion.

In this SQL tutorial, you’ll why is SQL and why you need it. You also learn the basics of SQL, type of SQL statements based on functionality and execution. Followed by SQL examples for better understanding.

Thank you for your support.

Read More…

Please Subscribe to Topictrick & Don’t forget to press THE BELL ICON to never miss any updates. Please visit below mention the link to stay connected with Topictrick.
Topictrick.com
Youtube
Follow us on Twitter
Facebook
Linkedin
Reddit
Mainframe Blog

Thank you for your support.

Topictrick™

Originally published at https://mainframe-forum.blogspot.com.

--

--

Topictrick.com

Topictrick is a comprehensive repository of programming language tutorial and tech reviews. Also, it showcases what new in the tech industry. One place for all.