STRUCTURE OF SQL QUERIES

VENNILAV6 5,197 views 8 slides Jan 20, 2020
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

DBS - STRUCTURE OF SQL QUERIES


Slide Content

BY Ms V.VENNILA MCA., M.Phil.., Assistant Professor Bon Secours College for Women, Thanjavur . BASIC STRUCTURE OF SQL QUERIES

Data Definition: Data definition refers to the set of SQL commands that can create and manipulate the structures of a database. DDL statements are used to create, change and remove objects including indexes, triggers, tables and views. Common DDL statements include CREATE (generates a new table) ALTER (alters table) DROP (removes a table from the database)

CREATE: Syntax : CREATE TABLE table name(column definitions,table parameters); Example: CREATE TABLE Employee(employee ID integer primary key, first name char(50),last name(75)) ALTER: Syntax: ALTER object type, object name parameters Example: ALTER TABLE Employee ADD DOB date

Drop: Syntax: DROP object type object name Example: DROP TABLE Employee BASIC STRUCTURE OF SQL QUERIES SQL is based on set relational operations with certain modification and enhancements. A typical SQL query has the form The Select clause The From clause The Where clause

The SELECT clause: The select clause list the attributes described in the result of a query. SQL allows duplicates in relations as well as in query results. The select clause can contain arithmetic expressions involving the operation +,-,* and / operating on constants o attributes of tuples . The WHERE clause: The where clause specifies conditions that the result must satisfy. Comparison results can be combined using the logical connectives and, or, not. Comparison can be applied to results of arithmetic expressions.

The FROM clause: The from clause is a source of a row set to be operated upon in a data manipulation language(DML) statement. The from is an SQL reserved word in the SQL standard. The from clause is used in conjunction with SQL statements. SET OPERATIONS IN SQL SQL supports few set operations which can be performed on the table data. These are used to get meaningful results from data stored in the table under different special conditions.

Types of set operations: Union Union all Intersect Minus Union Operation: Union is used to combine the results of two or more select statements. Union All: This operation is similar to union but it also shows the duplicate rows. Intersect: Intersect operation is used to combine two select statements.

Minus: The minus operation combines results of two select statements and return only those in the final result which belongs to the first set of the result.