Different Types of SQL operations In DB2
There are four types of SQL operations In DB2:-
DDL in DB2
We have three types of DDL statements in DB2
i) Create Statement – We use this statement to create a table or view or synonyms or alias.
ii) Alter Statement – This DDL statements in DB2 changes the property of the table, along with Alter we can use ALTER TABLE, ALTER VIEW, ALTER SYNONYM, and ALTER ALIAS.
iii)Drop Statement – This statement drop the table, along with Drop we can use DROP THE TABLE, DROP THE VIEW and DROP THE SYNONYMS.
When we use DROP, the drop statement completely drops the table from the database.
While DELETE is just a logical delete and it is a DML operation.
DML in DB2
DML is data manipulation language. In DML we have four types of statement.
i) INSERT– We can insert the records into the table.
ii) UPDATE– we can update a particular record based on particular condition and these conditions are all optional.
iii) DELETE– It is just a logical delete and it is a DML operation.
iv) SELECT– It is used to select a particular column or group of a column in a table.
DCL Operations in DB2
It is a Data Control Language. Mostly DBA uses GRANT REVOKE DCL, to give access to a particular area or table or public or particular group of users. You can also revoke the axis that is you can take back the access from a particular user or from the public using REVOKE.
As of now, we will not see about DCL operations in this tutorial because this is a part of DBA operation and DBA does all this job.
TCL Operations in DB2
It is a TRANSACTION CONTROL LANGUAGE. and it is not used directly in DB2, rather it is used in COBOL DB2 program inside the application program. Once you have created the COBOL DB2 program inside the program we can use DCL operation.
In TCL we have two statements:
i) COMMIT– It is used in an application program to commit the changes. For Example, if you want to COMMIT changes at a particular point, you can just give COMMIT in the program.
ii) ROLLBACK– It is used in the application program to roll back the changes. ROLLBACK has used to blackout the changes.
For Example, we want to back out the changes due to some condition or due to an event.