SQL of DBMS PRESENTATION
SQL of DBMS PRESENTATION
SQL of DBMS PRESENTATION
Topic: SQL
Submitted to : Dr. MONICA KHATRI
Topic: SQL
INTRODUCTION
SQL (Structured Query Language) is a computer
language aimed to store, manipulate, and retrieve data
stored in relational databases.
IBM implemented the language, originally called Sequel,
as part of the System R project in the early 1970s..
The first commercial relational database was released by
Relational Software later becoming oracle.
The SQL language has several parts:
Data-definition language (DDL). Provides commands for
defining relation schemas, deleting relations, and
modifying relation schemas.
Interactive data-manipulation language (DML). It
includes also commands to insert tuples into, delete tuples
from, and modify tuples in the database.
View definition. includes commands for defining views.
Transaction control. includes commands for specifying
the beginning and ending of transactions.
DDL
DDL - Data Definition Language:
Statements 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
RENAME - rename an object
Data Manipulation Language
DML- Data Manipulation Language:
Statements used for managing data within
schema objects.
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
CALL - call a PL/SQL or Java subprogram
Basic SQL Query
Select Clause :
1. select branch-name from loan Retain Duplicates
2. select distinct branch-name from loan Remove
duplicates
3. select all branch-name from loan Retain Duplicates
Where Clause :
1. select loan-number from loan where branch-name =
’Perryridge’ and amount > 1200
From Clause :
select customer-name, borrower.loan-number, amount
from borrower, loan where borrower.loan-number =
loan.loan-number
Basic SQL Query
Rename Operation :
select customer-name, borrower.loan-number as loan-id, amount from borrower, loan where
borrower.loannumber
= loan.loan-number
Tuple variables :
select customer-name, T.loan-number, S.amount from borrower as T, loan as S where T.loan-
number = S.loannumber Tuple variables are most useful for comparing two tuples in the same
relation.
String Operations :
select customer-name from customer where customerstreet like ’%Main%’
SQL INSERT, UPDATE, DELETE
Query with Example.
•After the INSERT clause, you should state which table you need to insert the
values into.
•After the table name you write the list of columns, you want to insert the values
into.
•You can ignore the columns name and don't write to them.
•If you don't write the columns name, the values will be inserted into all the
columns found in the table with the same order, the columns are defined in the
table.
•After the VALUES clause, you should list the values to be inserted.
•Each INSERT clause inserts only one row. If you want to insert multiple rows, you
should write multiple INSERT clauses, one for each row.
SQL Insert Example
INSERT INTO Students(StudentId, StudentName, DepartmentId, DateOfBirth)
VALUES(11, 'Ahmad', 4, '1997-10-12');
INSERT INTO Students VALUES(12, 'Aly', 4, '1996-10-12');
This should run successfully and you shouldn't get any output:
Thank you