You are on page 1of 6

Brief Overview of SQL

ICCS. 2018 – 1

Escuela Colombiana de Ingeniería Julio Garavito.

Note: Images, tables and content presented in this document are extracted from: SQL The Complete
Reference, Third Edition. ISBN: 978-0-07-159256-7. 2010. McGraw-Hill

SQL
Structured Query Language (SQL) is a tool for organizing, managing, and retrieving data stored by a
computer database. The computer program that controls the database is called a database management
system (DBMS).

When you need to retrieve data from a database, you use the SQL to make the request. The DBMS
processes the SQL request, retrieves the requested data, and returns it to you. This process of requesting
data from a database and receiving the results is called a database query—hence the name Structured
Query Language. SQL is used to control all of the functions that a DBMS provides for its users, including

• Data definition SQL lets a user define the structure and organization of the stored data and
relationships among the stored data items.
• Data retrieval SQL allows a user or an application program to retrieve stored data from the database
and use it.
• Data manipulation SQL allows a user or an application program to update the database by adding
new data, removing old data, and modifying previously stored data.
• Access control SQL can be used to restrict a user’s ability to retrieve, add, and modify data,
protecting stored data against unauthorized access.
• Data sharing SQL is used to coordinate data sharing by concurrent users, ensuring that changes
made by one user do not inadvertently wipe out changes made at nearly the same time by another
user.
• Data integrity SQL defines integrity constraints in the database, protecting it from corruption due to
inconsistent updates or system failures.
History
Statements
ANSI/ISO SQL Data Types
Example for a small distribution company Database

Tables:

• PRODUCTS Contains one row for each type of product that is available for sale.
• OFFICES Contains one row for each of the company’s five sales offices where the salespeople
work.
• SALESREPS Contains one row for each of the company’s ten salespeople.
• CUSTOMERS Contains one row for each of the company’s customers.
• ORDERS Contains one row for each order placed by a customer. For simplicity, each order is
assumed to be for a single product.

1. Access the SQL DBMS. This example and course related work are implemented using MySQL.
MySQL can be accessed locally or remotely. To run MySQL locally (Within the console), write the
following command:

mysql -u usuario -p

Remotely access can be achieved using SSH or the MySQL client named MySQL-Workbench. The
later connects to the MySQL-Server process through port 3306.

2. Create database:

CREATE DATABASE Ejemplo1;

3. Create tables according to the following structure

4. See the Appendix A to reproduce the example.


5. See the Chapter 6 to know about simple queries.

You might also like