Universidad Católica de Pereira
Facultad de Ciencias Básicas e Ingeniería
Bases de Datos II – Andrés Mauricio Martínez Hincapié
Junio 15 de 2020
Gestión de Bases de Datos
SQL, or Structured Query Language is the most popular declarative language used to work with
Relational Databases . Originally developed at IBM, it has been subsequently standardized by various
standards bodies (ANSI, ISO), and extended by various corporations adding their own features (T-SQL,
PL/SQL, etc.).
DDL - Data Definition Language (DDL) statements are used to define the database structure or
schema. Some examples:
• CREATE - to create objects in the database
• ALTER - alters the structure of the database
• DROP - delete objects from the database
• TRUNCATE - remove all records from a table, including all spaces allocated for the
records are removed
• COMMENT - add comments to the data dictionary
• RENAME - rename an object
DML Data Manipulation Language (DML) statements are used for managing data within schema
objects. Some examples:
• SELECT - retrieve data from the a database
• INSERT - insert data into a table
• UPDATE - updates existing data within a table
• DELETE - deletes all records from a table, the space for the records remain
• MERGE - UPSERT operation (insert or update)
• CALL - call a PL/SQL or Java subprogram
• EXPLAIN PLAN - explain access path to data
• LOCK TABLE - control concurrency
DCL - Data Control Language (DCL) statements. Some examples:
• GRANT - gives user's access privileges to database
• REVOKE - withdraw access privileges given with the GRANT command
TCL - Transaction Control (TCL) statements are used to manage the changes made by DML
statements. It allows statements to be grouped together into logical transactions.
• COMMIT - save work done
• SAVEPOINT - identify a point in a transaction to which you can later roll back
• ROLLBACK - restore database to original since the last COMMIT
• SET TRANSACTION - Change transaction options like isolation level and what rollback
segment to use
Activity
1. Practice DML commands (visit the web page: https://www.w3schools.com/sql/trysql.asp?
filename=trysql_select_all)
• Listar todos los empleados que son o tienen relación Ph.D
• Listar los productos que vienen en presentación por cajas
• Listar todos los proveedores de Ravenna
• Mostrar una lista de categorías y cantidad de productos que hay ordenados
• Obtener un listado de todos los clientes con la cantidad de ordenes que han realizado
• Mostrar el producto más ordenado
• Listar las categorías incluyendo la cantidad de productos que están relacionadas con cada una
• Mostrar los datos del mejor empleado
2. Create the script of the first exercise (DDL)
Fuentes:
http://www.theparticle.com/cs/bc/dbsys/sql.pdf
http://www.orafaq.com/faq/what_are_the_difference_between_ddl_dml_and_dcl_commands
http://www.tech-recipes.com/rx/55356/dml-ddl-dcl-and-tcl-statements-in-sql-with-examples/