We now describe the types of sql statements that we can find and their syntactic components.
In SQL we have quite a few statements that can be used to perform various tasks.
Depending on the tasks, these sentences can be classified into three main groups (DML, DDL, DCL), although we would have another group that in my opinion is not within the SQL language but PLSQL.
STATEMENT DESCRIPTION DML Data manipulation
select
INSERT
DELETE
UPDATE Retrieves data from the database.
Add new rows of data to the database.
Deletes rows of data from the database.
Modifies existing data in the database.
DDL Data Definition
CREATE TABLE
DROP TABLE
ALTER TABLE
CREATE VIEW
DROP VIEW
CREATE INDEX
DROP INDEX
CREATE SYNOM
DROP SYNONYM Adds a new table to the database.
Deletes a table from the database.
Modifies the structure of an existing table.
Add a new view to the database.
Deletes a view from the database.
Build an index for a column.
Deletes the index for a column.
Defines an alias for a table name.
Deletes an alias for a table name. DCL Access Control
GRANT
REVOKE
Transaction control
COMMIT
ROLLBACK Grants access privileges to users.
Remove user access privileges
Ends the current transaction.
Aborts the current transaction.
PLSQL Programmatic SQL
DECLARE
open
FETCH
CLOSE Defines a cursor for a query.
Opens a cursor to retrieve query results.
Retrieves a row of query results.
Close a cursor.
syntactic components
Most SQL statements have the same structure.
They all begin with a verb (select, insert, update, create), then it is followed by one or more clauses that tell us the data with which we are going to operate (from, where), some of these are optional and others are mandatory, such as the case of from.