TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

DB2 - SQL Introduction


SQL is a standard language for accessing and manipulating databases. SQL is used to obtain and manipulate data that is stored in Db2 tables. SQL consists of more than 100 different statements that can be used to insert, query, update, delete, and authorize access to Db2 data.

One of the most commonly used SQL statements is SELECT. This statement is used to query a table and produce results that are in a table format.

There are a number of built-in and user-defined functions available in SQL.


What can SQL do?

  1. Execute queries against a database

  2. Retrieve data from a database

  3. Insert records in a database

  4. Update records in a database

  5. Delete records from a database

  6. Create new databases

  7. Create new tables in a database

  8. Create stored procedures in a database

  9. Create views in a database

  10. Set permissions on tables, procedures, and views


SQL Statements:

Most of the actions you need to perform on a database are done with SQL statements.

The following SQL statement selects all the records in the "STUDENTS" table:

SELECT * FROM STUDENTS;

Symbol '*' indicates all column should be selected from the table STUDENTS.

Note: SQL keywords are NOT case sensitive: select is the same as SELECT.

Do we need semicolon(;) at the end of SQL statement?

Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.


Important SQL Commands listed below:

  1. SELECT - Extracts data from a database

  2. UPDATE - Updates data in a database

  3. DELETE - Deletes data from a database

  4. INSERT INTO - Inserts new data into a database

  5. CREATE DATABASE - Creates a new database

  6. ALTER DATABASE - Modifies a database

  7. CREATE TABLE - Creates a new table

  8. ALTER TABLE - Modifies a table

  9. DROP TABLE - Deletes a table

  10. CREATE INDEX - Creates an index (search key)

  11. DROP INDEX - Deletes an index



If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal