0% found this document useful (0 votes)
50 views

SQL (Structured Query Language)

SQL is a standard language used to communicate with relational database management systems. It allows users to perform tasks like creating tables, querying data, modifying data, deleting data, and granting access to users. The key aspects of SQL include data manipulation language to insert, delete, and modify data; data definition language to create, delete, and modify database structures; and triggers, embedded/dynamic SQL, client/server execution, transaction management, and security features. SQL uses tables, columns, rows and a basic query structure of SELECT, FROM, WHERE clauses. For example, one query finds the name and age of all sailors by selecting those columns from the Sailors table.

Uploaded by

Vivek Raj
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

SQL (Structured Query Language)

SQL is a standard language used to communicate with relational database management systems. It allows users to perform tasks like creating tables, querying data, modifying data, deleting data, and granting access to users. The key aspects of SQL include data manipulation language to insert, delete, and modify data; data definition language to create, delete, and modify database structures; and triggers, embedded/dynamic SQL, client/server execution, transaction management, and security features. SQL uses tables, columns, rows and a basic query structure of SELECT, FROM, WHERE clauses. For example, one query finds the name and age of all sailors by selecting those columns from the Sailors table.

Uploaded by

Vivek Raj
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL ( Structured Query Language)

Definition:- SQL is the standard command set used to


communicate with the relational database management systems.
All the tasks related to relational database management system-
creating tables, querying the database for information, modifying
the data in the database, deleting them, granting access to users
can be done by SQL.

All vendors use different dialects of SQL that have same base-
ANSI SQL standard.

Overview

SQL has several aspects to it:-

1. Data Manipulation Language (DML):-This subset of SQL


allows users to pose queries and to insert, delete and modify
rows.

DML commands to insert, delete and modify rows.

2. Data Definition Language (DDL):-This subset of SQL allows


creation, deletion and modification of definitions for tables
and views. Integrity constraints can be defined on table.

3. Triggers and Advanced Integrity Constraint:-Triggers are the


actions executed by the DBMS whenever changes to the
database meet conditions specified in the triggers

4. Embeddded and Dynamic SQL:-Embedded SQL features allow


SQL code to be called from host language such as C. Dynamic
SQl feature allow the query to be constructed at the run
time.
5. Client Server Execution and Remote Database Access:-These
commands control how a client application program can
connect to an SQL database server or access data from a
database over a network.

6. Transaction Management:-Various commands allow user to


explicity control aspects how a transaction is executed.

7. Security:-SQl provides mechanism to control user access to


data objects such as tables and views.

8. Advanced Features:- The SQL includes Object oriented


features,recursive Queries,text and XML data management.

SQL Query uses following Tables Definition:-

Sailors(sid:integer,sname:string,rating:integer,age:real)

Boats(bid:integer,bname:string,color:string)

Reserves(sid:integer,bid:integer,day:date)

The form of a Basic SQl Query:-

SELECT [DISTINCT] select-list

FROM from-list

WHERE qualification.

Sid Sname Rating Age


22 Dustin 7 45.0
29 Brutus 1 33.0
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35.0
64 Horatio 7 35.0
71 Zorba 10 16.0
74 Horatio 9 35.0
85 Art 3 25.5
95 Bob 3 63.5
An instance of S3 of Sailors

Every query must have a SELECT clause,which specifies columns


to be retained in the result and a FROM clause, which specify the
cross product of the table.The optional WHERE clause specifies
selection conditions on the tables mentioned in the FROM clause.

Such a query intuitively correspond to a relational algebra


expression involving selections,projections and cross product.

Eg.Q1 Find the name and age of all the sailors.

SELECT DISTINCT S.name,S.age FROM Sailors S

The answer is the set of rows each of which is a pair


<sname,age>.If two or more sailors have the same name and
age ,the answer still contains just one pair with that name and
age.

If we omit DISTINCT we would get a copy of rows <s,a> for each


sailor with name s and age a,the answer would be multiset of
rows.

A multiset is similar to a set in that it is an unorderes collection of


elements,but there could be several copies of each element.

Q2. Find all Sailors with a rating above 7.

SELECT S.sid,S.same,S.rating,S.age FROM Sailors AS S WHERE


S.rating >7

Syntax of SQL in detail

1. The from-list in the FROm clause is the list of table names.


2. The select list is the list of column names of tables named in
from list

3. The Qualification in the WHERE clause is the Boolean


combination

4. The DISTINCT keyword is optional It indicate that table


should not contain duplicates i.e two copies of same rows.

You might also like