BY Ms V.VENNILA MCA., M.Phil.., Assistant Professor Bon Secours College for Women, Thanjavur.
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.

STRUCTURE OF SQL QUERIES

  • 1.
    BY Ms V.VENNILA MCA.,M.Phil.., Assistant Professor Bon Secours College for Women, Thanjavur.
  • 2.
    Data Definition:  Datadefinition 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)
  • 3.
    CREATE: Syntax: CREATE TABLE tablename(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
  • 4.
    Drop: Syntax: DROP object typeobject 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
  • 5.
    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.
  • 6.
    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.
  • 7.
    Types of setoperations:  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.
  • 8.
    Minus: The minus operationcombines results of two select statements and return only those in the final result which belongs to the first set of the result.