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.
Execute queries against a database
Retrieve data from a database
Insert records in a database
Update records in a database
Delete records from a database
Create new databases
Create new tables in a database
Create stored procedures in a database
Create views in a database
Set permissions on tables, procedures, and views
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.
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.
SELECT - Extracts data from a database
UPDATE - Updates data in a database
DELETE - Deletes data from a database
INSERT INTO - Inserts new data into a database
CREATE DATABASE - Creates a new database
ALTER DATABASE - Modifies a database
CREATE TABLE - Creates a new table
ALTER TABLE - Modifies a table
DROP TABLE - Deletes a table
CREATE INDEX - Creates an index (search key)
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!