Academy Training Slides - Introduction To SQL

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Introduction to

SQL
WHAT IS SQL?

 SQL stands for Structured Query Language


 SQL lets you access and manipulate databases
 SQL became a standard of the American National Standards
Institute (ANSI) in 1986, and of the International
Organization for Standardization (ISO) in 1987
TYPES OF DATABASES
DATABASES OBJECTS

Function Tables

Inde Stored
x Procedures

Views
DATABASES TABLE
TYPES OF QUERY

Data Definition Language (DDL)


This defines the structure or schema of the database.
It affects the entire table data. Changes are permanent. It
helps in defining the fields or columns of the tables. They are
auto-committed (changes made are permanent). Commands
used: CREATE, ALTER, TRUNCATE, RENAME, DROP.
TYPES OF QUERY (Cont’d)
Data Manipulation Language (DML)
This helps us deal with managing and manipulating data in
the database. It only affects the specified row(s) of the table.
We can roll back our changes in the DML language. It helps
us to define rows or records of the tables. They are not auto-
committed (changes are not permanent). Commands used:
SELECT, UPDATE, DELETE, INSERT.
TYPES OF QUERY

Data Control Language (DCL)


This helps us deal with controls, rights, and permission in
the database system. It helps us to control the access and
permission of the database. It applies to the complete table.
It helps us to control access to the information in the
database. Commands used: REVOKE, GRANT.
IMPORTANT DML SQL COMMANDS

•SELECT - extracts data/records from a database table.


•UPDATE - modifies data/records in a database table.
•DELETE - removes data/records from a database table.
•INSERT INTO - adds new data/record(s) into a database table.
SELECT STATEMENT

SELECT Syntax

SELECT column1, column2, ...


FROM [table_name];

Here, column1, column2, ... are the field names of the table
you want to select data from. If you want to select all the
fields available in the table, use the following syntax:

SELECT * FROM [table_name];


UPDATE STATEMENT

UPDATE Syntax

UPDATE [table_name]
SET column1=‘XXXXXX’, column2=‘YYYYYYY’, ...
WHERE <Condition>

Note: Be careful when updating records in a table! Notice the


WHERE clause in the UPDATE statement. The WHERE
clause specifies which record(s) that should be updated. If
you omit the WHERE clause, all records in the table will be
updated!
DELETE STATEMENT

DELETE Syntax

DELETE
FROM [table_name]
WHERE <Condition>

Note: Be careful when deleting records in a table! Notice the


WHERE clause in the DELETE statement. The WHERE clause
specifies which record(s) should be deleted. If you omit the
WHERE clause, all records in the table will be deleted!
INSERT STATEMENT

INSERT Syntax

INSERT INTO table_name (column1, column2, column3, ...)


VALUES (value1, value2, value3, ...);

If you are adding values for all the columns of the table, you do not
need to specify the column names in the SQL query. However, make
sure the order of the values is in the same order as the columns in the
table. The INSERT INTO syntax would be as follows:

INSERT INTO table_name


VALUES (value1, value2, value3, ...);

You might also like