Sunteți pe pagina 1din 68

INTRODUCTION TO SQL

SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel – (Structured
English Query Language)”. It is a query language used for accessing and modifying information in the database.
IBM first developed SQL in 1970s. Also it is an ANSI/ISO standard. It has become a Standard Universal
Language used by most of the relational database management systems (RDBMS). Some of the RDBMS
systems are: Oracle, Microsoft SQL server, Sybase etc. Most of these have provided their own implementation
thus enhancing its feature and making it a powerful tool. Few of the SQL commands used in SQL programming
are SELECT Statement, UPDATE Statement, INSERT INTO Statement, DELETE Statement, WHERE Clause,
ORDER BY Clause, GROUP BY Clause, ORDER Clause, Joins, Views, GROUP Functions, Indexes etc.

SQL Commands

SQL commands are instructions used to communicate with the database to perform specific task that work with
data. SQL commands can be used not only for searching the database but also to perform various other
functions like, for example, you can create tables, add data to tables, or modify data, drop the table, set
permissions for users. SQL commands are grouped into four major categories depending on their functionality:
 Data Definition Language (DDL) - These SQL commands are used for creating, modifying,
and dropping the structure of database objects. The commands are CREATE, ALTER, DROP,
RENAME, and TRUNCATE.
 Data Manipulation Language (DML) - These SQL commands are used for storing,
retrieving, modifying and deleting data. These commands are SELECT, INSERT, UPDATE,
and DELETE.
 Transaction Control Language (TCL) - These SQL commands are used for managing
changes affecting the data. These commands are COMMIT, ROLLBACK, and SAVEPOINT.
 Data Control Language (DCL) - These SQL commands are used for providing security to
database objects. These commands are GRANT and REVOKE.
 SQL can execute queries against a database

 SQL can retrieve data from a database


 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
 SQL can create new databases
 SQL can create new tables in a database
 SQL can create stored procedures in a database
 SQL can create views in a database
 SQL can set permissions on tables, procedures, and views

RDBMS

1
RDBMS stands for Relational Database Management System.RDBMS is the basis for SQL, and for all modern
database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and
it consists of columns and rows.

Look at the "Customers" table:

Example
SELECT * FROM Customers;

Every table is broken up into smaller entities called fields. The fields in the Customers table consist of
CustomerID, CustomerName, ContactName, Address, City, PostalCode and Country. A field is a column in a
table that is designed to maintain specific information about every record in the table.

A record, also called a row, is each individual entry that exists in a table. For example, there are 91 records in
the above Customers table. A record is a horizontal entity in a table.

A column is a vertical entity in a table that contains all information associated with a specific field in a table.

2
DDL AND DML COMMANDS
EXP NO: 1

AIM
To execute DDL and DML commands using SQL

OBJECTIVE:

DDL: Data Definition Language

These SQL commands are used for creating, modifying, and dropping the structure of database objects. The
commands are CREATE, ALTER, DROP, RENAME, and TRUNCATE.

DML: Data Manipulation Language

These SQL commands are used for storing, retrieving, modifying and deleting data. These commands are
SELECT, INSERT, UPDATE, and DELETE.

PROCEDURE:

CREATE TABLE:
The CREATE TABLE Statement is used to create tables to store data. Integrity Constraints like primary key,
unique key and foreign key can be defined for the columns while creating the table. The integrity constraints
can be defined at column level or table level. The implementation and the syntax of the CREATE Statements
differs for different RDBMS.
The Syntax for the CREATE TABLE Statement is:

CREATE TABLE table_name (column_name1 datatype constraint, column_name2 datatype, ...


column_nameNdatatype);

 table_name - is the name of the table.


 column_name1, column_name2.... - is the name of the columns
 datatype - is the datatype for the column like char, date, number etc.

3
QUERY:
CREATE TABLE EMPLOYEE(EMPLOYEE_NAME VARCHAR(10), EMPLOYEE_NO INT, DEPT_NAME
VARCHAR(10),DEPT_NO INT,DATE_OF_JOIN DATE)
INSERT INTO EMPLOYEE VALUES('VIJAY',345,'CSE',21,'21-JUN-2006')
INSERT INTO EMPLOYEE VALUES('RAJ',098,'IT',22,'30-SEP-2006')
INSERT INTO EMPLOYEE VALUES('GIRI',100,'CSE',67,'14-NOV-1981')

SELECT:

The SELECT statement is used to select data from a database.The result is stored in a result table, called the
result-set.
SELECT Syntax:
SELECT * FROM table_name;
QUERY:
SELECT *FROM EMPLOYEE

The SELECT DISTINCT Statement


In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you
will want to list only the different (distinct) values in a table.The DISTINCT keyword can be used to return only
distinct (different) values.
SELECT DISTINCT Syntax:
SELECT DISTINCT column_name(s) FROM table_name;
The WHERE Clause
The WHERE clause is used to extract only those records that fulfill a specified criterion.
WHERE Syntax:
SELECT column_name(s) FROM table_name WHERE column_name operator value;

CREATE TABLE EMPLOYEE1 (EMPLOYEE_NAME VARCHAR(10), EMPLOYEE_NO INT PRIMARY


KEY, DEPT_NAME VARCHAR(10),DEPT_NO INT,DATE_OF_JOIN DATE)

INSERT INTO:

The INSERT INTO statement is used to insert a new row in a table.


SQL INSERT INTO Syntax:
It is possible to write the INSERT INTO statement in two forms.
 The first form doesn't specify the column names where the data will be inserted, only their values:

INSERT INTO table_nameVALUES (value1, value2, value3,...);


OR
INSERT INTO table_nameVALUES(&column1, &column2, &column3,...);

4
 The second form specifies both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...);

INSERT INTO EMPLOYEE1 VALUES('VIJAY',345,'CSE',21,'21-JUN-2006')


INSERT INTO EMPLOYEE1 VALUES('RAJ',098,'IT',22,'30-SEP-2006')
INSERT INTO EMPLOYEE1 VALUES('GIRI',100,'CSE',67,'14-NOV-1981')
INSERT INTO EMPLOYEE1 VALUES('SAI',100,'EEE',91,'27-JUN-1996')
SELECT *FROM EMPLOYEE1

ALTER TABLE:
The SQL ALTER TABLE command is used to modify the definition structure) of a table by modifying the
definition of its columns. The ALTER command is used to perform the following functions.
1) Add, drop, modify table columns 2) Add and drop constraints 3) Enable and Disable constraints

Syntax to add a column

ALTER TABLE table_name ADD column_namedatatype;

QUERY:
alter table employee add age int
SELECT *FROM EMPLOYEE

UPDATE:
he UPDATE statement is used to update existing records in a table.

UPDATE Syntax:
UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value;

QUERY:
update EMPLOYEE set age = 25 where EMPLOYEE_NAME ='Vijay'
SELECT *FROM EMPLOYEE

UPDATE EMPLOYEE1 SET EMPLOYEE_NO=300 WHERE DEPT_NO=67


SELECT *FROM EMPLOYEE1
5
DELETE:
The DELETE statement is used to delete rows in a table.

SQL DELETE Syntax:


DELETE FROM table_name WHERE some_column=some_value;

QUERY:
DELETE FROM EMPLOYEE1 WHERE EMPLOYEE_NO>344
SELECT *FROM EMPLOYEE1

TRUNCATE TABLE:

What if we only want to delete the data inside the table, and not the table itself?
Then, use the TRUNCATE TABLE statement:

SYNTAX:
TRUNCATE TABLE table_name;
QUERY:
TRUNCATE TABLE EMPLOYEE1
SELECT *FROM EMPLOYEE1

DROP TABLE:

The DROP TABLE statement is used to delete a table.


SYNTAX:
DROP TABLE table_name;
QUERY:
DROP TABLE EMPLOYEE1
SELECT *FROM EMPLOYEE1

6
RESULT:
Thus the DDL and DML Statements have been successfully executed using SQL.

NESTED QUERIES
EXP NO: 2

AIM
To execute Nested Queries using SQL

OBJECTIVE:
A Subquery or Inner query or a Nested query is a query within another SQL query and embedded within the
WHERE clause.

A subquery is used to return data that will be used in the main query as a condition to further restrict the data to
be retrieved.

Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the
operators like =, <, >, >=, <=, IN, BETWEEN, etc.

There are a few rules that subqueries must follow −

 Subqueries must be enclosed within parentheses.

 A subquery can have only one column in the SELECT clause, unless multiple columns are in the main
query for the subquery to compare its selected columns.

 An ORDER BY command cannot be used in a subquery, although the main query can use an ORDER
BY. The GROUP BY command can be used to perform the same function as the ORDER BY in a
subquery.

 Subqueries that return more than one row can only be used with multiple value operators such as the IN
operator.

7
 The SELECT list cannot include any references to values that evaluate to a BLOB, ARRAY, CLOB, or
NCLOB.

 A subquery cannot be immediately enclosed in a set function.

 The BETWEEN operator cannot be used with a subquery. However, the BETWEEN operator can be
used within the subquery.

Subqueries with the SELECT Statement


Subqueries are most frequently used with the SELECT statement. The basic syntax is as follows −

SELECT column_name [, column_name ]


FROM table1 [, table2 ]
WHERE column_name OPERATOR
(SELECT column_name [, column_name ]
FROM table1 [, table2 ]
[WHERE])

PROCEDURE:

CREATE TABLE BOOK(ISBN INT,TITLE VARCHAR(10),PUB_YEAR INT, UNIT_PRICE MONEY,


AUTHOR_NAME VARCHAR(10), PUBLISHER_NAME VARCHAR(10))
INSERT INTO BOOK VALUES(1001,'ORACLE',2004,399,'ARORA','PHI')
INSERT INTO BOOK VALUES(1002,'DBMS',2004,400,'BASU','TECHNICAL')
INSERT INTO BOOK VALUES(2001,'DOS',2003,250,'SINHA','NIRALI')
INSERT INTO BOOK VALUES(2002,'UNIX',2004,450,'BASU','PEARSON')
INSERT INTO BOOK VALUES(2003,'DAA',2000,300,'KAPOOR','SCITECH')
INSERT INTO BOOK VALUES(2002,'COA',2000,700,'ARORA','PHI')
SELECT *FROM BOOK

CREATE TABLE AUTHOR(AUTHOR_NAME VARCHAR(10), COUNTRY VARCHAR(10))


INSERT INTO AUTHOR VALUES('ARORA','US')
INSERT INTO AUTHOR VALUES('KAPOOR','CANADA')
INSERT INTO AUTHOR VALUES('BASU','INDIA')
INSERT INTO AUTHOR VALUES('SINHA','INDIA')
SELECT *FROM AUTHOR

8
CREATE TABLE PUBLISHER (PUBLISHER_NAME VARCHAR(10),PUBLISHER_ADDRESS
VARCHAR(10))
INSERT INTO PUBLISHER VALUES('PHI','DELHI')

INSERT INTO PUBLISHER VALUES('TECHNICAL','PUNE')


INSERT INTO PUBLISHER VALUES('NIRALI','MUMBAI')

INSERT INTO PUBLISHER VALUES('SCITECH','CHENNAI')


INSERT INTO PUBLISHER VALUES('PEARSON','CALCUTTA')
SELECT *FROM PUBLISHER

IN
1. SELECT TITLE, AUTHOR_NAME, PUBLISHER_NAME FROM BOOK WHERE PUB_YEAR IN
( 2000,2002,2004)

2. SELECT *FROM AUTHOR WHERE AUTHOR_NAME IN (SELECT AUTHOR_NAME FROM


BOOK WHERE PUB_YEAR=2004)

NOT IN
3. SELECT TITLE,AUTHOR_NAME,PUBLISHER_NAME FROM BOOK WHERE PUB_YEAR NOT
IN(2002,2004,2005)

9
SOME
4. SELECT TITLE FROM BOOK WHERE UNIT_PRICE>SOME(SELECT UNIT_PRICE FROM
BOOK WHERE PUB_YEAR=2004)

ALL
5. SELECT TITLE FROM BOOK WHERE UNIT_PRICE>ALL(SELECT UNIT_PRICE FROM BOOK
WHERE PUB_YEAR=2004)

10
RESULT:
Thus the Nested Queries have been successfully executed using SQL.

AGGREGATE FUNCTIONS
EXP NO: 3

AIM
To execute Aggregate functions using SQL

OBJECTIVE:

An aggregate function allows you to perform a calculation on a set of values to return a single scalar value. We
often use aggregate functions with the GROUP BY and HAVING clauses of the SELECT statement.

The following are the most commonly used SQL aggregate functions:

 AVG – calculates the average of a set of values.


 COUNT – counts rows in a specified table or view.

 MIN – gets the minimum value in a set of values.

 MAX – gets the maximum value in a set of values.

 SUM – calculates the sum of values.

Notice that all aggregate functions above ignore NULL values except for the COUNT function.

SQL aggregate functions syntax

11
To call an aggregate function, you use the following syntax:

1 aggregate_function (DISTINCT | ALL expression)

PROCEDURE:

SQL aggregate function examples

Let’s take a look some examples of using SQL aggregate functions.

COUNT function example

To get the number of products in the products table, you use the COUNT function as follows:

SELECT
COUNT(*)
FROM
products;

More information on the COUNT function.

AVG function example

To calculate the average units in stock of the products, you use the AVG function as follows:

SELECT
AVG(unitsinstock)
FROM
products;

To calculate units in stock by product category, you use the AVG function with the GROUP BY clause as
follows:

SELECT
categoryid, AVG(unitsinstock)
FROM
products
GROUP BY categoryid;

12
More information on AVG function.

SUM function example

To calculate the sum of units in stock by product category, you use the SUM function with the GROUP
BYclause as the following query:

SELECT
categoryid, SUM(unitsinstock)
FROM
products
GROUP BY categoryid;

MIN function example

To get the minimum units in stock of products in the products table, you use the MIN function as follows:

SELECT
MIN(unitsinstock)
FROM
products;

MAX function example

13
To get the maximum units in stock of products in the products table, you use the MAX function as shown in the
following query:

SELECT
MAX(unitsinstock)
FROM
products;

RESULT:

Thus Aggregate functions have been successfully executed using SQL.

JOINS
EXP NO: 4

AIM
To execute Joins queries using SQL

OBJECTIVE:

The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for
combining fields from two tables by using values common to each.

There are different types of joins available in SQL −

 INNER JOIN − returns rows when there is a match in both tables.

 LEFT JOIN − returns all rows from the left table, even if there are no matches in the right table.

 RIGHT JOIN − returns all rows from the right table, even if there are no matches in the left table.

 FULL JOIN − returns rows when there is a match in one of the tables.

14
 SELF JOIN − is used to join a table to itself as if the table were two tables, temporarily renaming at
least one table in the SQL statement.

 CARTESIAN JOIN − returns the Cartesian product of the sets of records from the two or more joined
tables.

PROCEDURE:

Consider the following two tables −

Table 1 − CUSTOMERS Table

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2 − ORDERS Table

+-----+---------------------+-------------+--------+

|OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

15
+-----+---------------------+-------------+----

Now, let us join these two tables in our SELECT statement as shown below.

SQL> SELECT ID, NAME, AGE, AMOUNT

FROM CUSTOMERS, ORDERS

WHERE CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

This would produce the following result.

+----+----------+-----+--------+
| ID | NAME | AGE | AMOUNT |
+----+----------+-----+--------+
| 3 | kaushik | 23 | 3000 |
| 3 | kaushik | 23 | 1500 |
| 2 | Khilan | 25 | 1560 |
| 4 | Chaitali | 25 | 2060 |
+----+----------+-----+--------+
Here, it is noticeable that the join is performed in the WHERE clause. Several operators can be used to join
tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables.
However, the most common operator is the equal to symbol.

INNER JOIN

creates a new result table by combining column values of two tables (table1 and table2) based upon the join-
predicate. The query compares each row of table1 with each row of table2 to find all pairs of rows which
satisfy the join-predicate. When the join-predicate is satisfied, column values for each matched pair of rows of
A and B are combined into a result row.

Syntax
The basic syntax of the INNER JOIN is as follows.

SELECT table1.column1, table2.column2...


FROM table1
INNER JOIN table2
ON table1.common_field = table2.common_field;

Consider the following two tables.

Table 1 − CUSTOMERS Table is as follows.

+----+----------+-----+-----------+----------+

16
| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2 − ORDERS Table is as follows.

+-----+---------------------+-------------+--------+

| OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

+-----+---------------------+-------------+--------

Now, let us join these two tables using the INNER JOIN as follows −

SQL> SELECT ID, NAME, AMOUNT, DATE

FROM CUSTOMERS

INNER JOIN ORDERS

ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

This would produce the following result.

17
+----+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+----+----------+--------+---------------------+
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
+----+----------+--------+---------------------+

The SQL LEFT JOIN returns all rows from the left table, even if there are no matches in the right table. This
means that if the ON clause matches 0 (zero) records in the right table; the join will still return a row in the
result, but with NULL in each column from the right table.

This means that a left join returns all the values from the left table, plus matched values from the right table or
NULL in case of no matching join predicate.

Syntax
The basic syntax of a LEFT JOIN is as follows.

SELECT table1.column1, table2.column2...


FROM table1
LEFT JOIN table2
ON table1.common_field = table2.common_field;
Here, the given condition could be any given expression based on your requirement.

Consider the following two tables,

Table 1 − CUSTOMERS Table is as follows.

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

18
| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2 − Orders Table is as follows.

+-----+---------------------+-------------+--------+

| OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

+-----+---------------------+-------------+--------+

Now, let us join these two tables using the LEFT JOIN as follows.

SQL> SELECT ID, NAME, AMOUNT, DATE

FROM CUSTOMERS

LEFT JOIN ORDERS

ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

This would produce the following result −

+----+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+----+----------+--------+---------------------+
| 1 | Ramesh | NULL | NULL |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
| 5 | Hardik | NULL | NULL |
| 6 | Komal | NULL | NULL |
| 7 | Muffy | NULL | NULL |
+----+----------+--------+---------------------+

19
The SQL RIGHT JOIN returns all rows from the right table, even if there are no matches in the left table.
This means that if the ON clause matches 0 (zero) records in the left table; the join will still return a row in the
result, but with NULL in each column from the left table.

This means that a right join returns all the values from the right table, plus matched values from the left table
or NULL in case of no matching join predicate.

Syntax
The basic syntax of a RIGHT JOIN is as follow.

SELECT table1.column1, table2.column2...


FROM table1
RIGHT JOIN table2
ON table1.common_field = table2.common_field;

Example
Consider the following two tables,

Table 1 − CUSTOMERS Table is as follows.

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2 − ORDERS Table is as follows.

+-----+---------------------+-------------+--------+

|OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

20
| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

+-----+---------------------+-------------+--------+

Now, let us join these two tables using the RIGHT JOIN as follows.

SQL> SELECT ID, NAME, AMOUNT, DATE

FROM CUSTOMERS

RIGHT JOIN ORDERS

ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

This would produce the following result −

+------+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+------+----------+--------+---------------------+
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
+------+----------+--------+---------------------+
The SQL FULL JOIN combines the results of both left and right outer joins.

The joined table will contain all records from both the tables and fill in NULLs for missing matches on either
side.

Syntax
The basic syntax of a FULL JOIN is as follows −

SELECT table1.column1, table2.column2...


FROM table1
FULL JOIN table2
ON table1.common_field = table2.common_field;
Here, the given condition could be any given expression based on your requirement.

Example
Consider the following two tables.

Table 1 − CUSTOMERS Table is as follows.

21
+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2 − ORDERS Table is as follows.

+-----+---------------------+-------------+--------+

|OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

+-----+---------------------+-------------+--------+

Now, let us join these two tables using FULL JOIN as follows.

SQL> SELECT ID, NAME, AMOUNT, DATE

FROM CUSTOMERS

FULL JOIN ORDERS

ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;

This would produce the following result −

22
+------+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+------+----------+--------+---------------------+
| 1 | Ramesh | NULL | NULL |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
| 5 | Hardik | NULL | NULL |
| 6 | Komal | NULL | NULL |
| 7 | Muffy | NULL | NULL |
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
+------+----------+--------+---------------------+

The SQL SELF JOIN is used to join a table to itself as if the table were two tables; temporarily renaming at
least one table in the SQL statement.

Syntax
The basic syntax of SELF JOIN is as follows −

SELECT a.column_name, b.column_name...


FROM table1 a, table1 b
WHERE a.common_field = b.common_field;
Here, the WHERE clause could be any given expression based on your requirement.

Example
Consider the following table.

CUSTOMERS Table is as follows.

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

23
| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Now, let us join this table using SELF JOIN as follows −

SQL> SELECT a.ID, b.NAME, a.SALARY

FROM CUSTOMERS a, CUSTOMERS b

WHERE a.SALARY < b.SALARY;

This would produce the following result −

+----+----------+---------+
| ID | NAME | SALARY |
+----+----------+---------+
| 2 | Ramesh | 1500.00 |
| 2 | kaushik | 1500.00 |
| 1 | Chaitali | 2000.00 |
| 2 | Chaitali | 1500.00 |
| 3 | Chaitali | 2000.00 |
| 6 | Chaitali | 4500.00 |
| 1 | Hardik | 2000.00 |
| 2 | Hardik | 1500.00 |
| 3 | Hardik | 2000.00 |
| 4 | Hardik | 6500.00 |
| 6 | Hardik | 4500.00 |
| 1 | Komal | 2000.00 |
| 2 | Komal | 1500.00 |
| 3 | Komal | 2000.00 |
| 1 | Muffy | 2000.00 |
| 2 | Muffy | 1500.00 |
| 3 | Muffy | 2000.00 |
| 4 | Muffy | 6500.00 |
| 5 | Muffy | 8500.00 |
| 6 | Muffy | 4500.00 |
+----+----------+---------+
The CARTESIAN JOIN or CROSS JOIN returns the Cartesian product of the sets of records from two or more
joined tables. Thus, it equates to an inner join where the join-condition always evaluates to either True or
where the join-condition is absent from the statement.

Syntax
The basic syntax of the CARTESIAN JOIN or the CROSS JOIN is as follows −

SELECT table1.column1, table2.column2...

24
FROM table1, table2 [, table3 ]

Example
Consider the following two tables.

Table 1 − CUSTOMERS table is as follows.

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Table 2: ORDERS Table is as follows −

+-----+---------------------+-------------+--------+

|OID | DATE | CUSTOMER_ID | AMOUNT |

+-----+---------------------+-------------+--------+

| 102 | 2009-10-08 00:00:00 | 3 | 3000 |

| 100 | 2009-10-08 00:00:00 | 3 | 1500 |

| 101 | 2009-11-20 00:00:00 | 2 | 1560 |

| 103 | 2008-05-20 00:00:00 | 4 | 2060 |

+-----+---------------------+-------------+--------+

Now, let us join these two tables using CARTESIAN JOIN as follows −

SQL> SELECT ID, NAME, AMOUNT, DATE

FROM CUSTOMERS, ORDERS;

25
This would produce the following result −

+----+----------+--------+---------------------+
| ID | NAME | AMOUNT | DATE |
+----+----------+--------+---------------------+
| 1 | Ramesh | 3000 | 2009-10-08 00:00:00 |
| 1 | Ramesh | 1500 | 2009-10-08 00:00:00 |
| 1 | Ramesh | 1560 | 2009-11-20 00:00:00 |
| 1 | Ramesh | 2060 | 2008-05-20 00:00:00 |
| 2 | Khilan | 3000 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1500 | 2009-10-08 00:00:00 |
| 2 | Khilan | 1560 | 2009-11-20 00:00:00 |
| 2 | Khilan | 2060 | 2008-05-20 00:00:00 |
| 3 | kaushik | 3000 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1500 | 2009-10-08 00:00:00 |
| 3 | kaushik | 1560 | 2009-11-20 00:00:00 |
| 3 | kaushik | 2060 | 2008-05-20 00:00:00 |
| 4 | Chaitali | 3000 | 2009-10-08 00:00:00 |
| 4 | Chaitali | 1500 | 2009-10-08 00:00:00 |
| 4 | Chaitali | 1560 | 2009-11-20 00:00:00 |
| 4 | Chaitali | 2060 | 2008-05-20 00:00:00 |
| 5 | Hardik | 3000 | 2009-10-08 00:00:00 |
| 5 | Hardik | 1500 | 2009-10-08 00:00:00 |
| 5 | Hardik | 1560 | 2009-11-20 00:00:00 |
| 5 | Hardik | 2060 | 2008-05-20 00:00:00 |
| 6 | Komal | 3000 | 2009-10-08 00:00:00 |
| 6 | Komal | 1500 | 2009-10-08 00:00:00 |
| 6 | Komal | 1560 | 2009-11-20 00:00:00 |
| 6 | Komal | 2060 | 2008-05-20 00:00:00 |
| 7 | Muffy | 3000 | 2009-10-08 00:00:00 |
| 7 | Muffy | 1500 | 2009-10-08 00:00:00 |
| 7 | Muffy | 1560 | 2009-11-20 00:00:00 |
| 7 | Muffy | 2060 | 2008-05-20 00:00:00 |
+----+----------+--------+---------------------+

26
RESULT:

Thus Join queries been successfully executed using SQL.

27
VIEWS AND SET OPERATORS
EXP NO: 5

AIM
To execute VIEWS and SET operators using SQL

OBJECTIVE:

A view is nothing more than a SQL statement that is stored in the database with an associated name. A view is
actually a composition of a table in the form of a predefined SQL query.

A view can contain all rows of a table or select rows from a table. A view can be created from one or many
tables which depends on the written SQL query to create a view.

Views, which are a type of virtual tables allow users to do the following −

 Structure data in a way that users or classes of users find natural or intuitive.

 Restrict access to the data in such a way that a user can see and (sometimes) modify exactly what they
need and no more.

 Summarize data from various tables which can be used to generate reports.

PROCEDURE

A view is nothing more than a SQL statement that is stored in the database with an associated name. A view is
actually a composition of a table in the form of a predefined SQL query.

A view can contain all rows of a table or select rows from a table. A view can be created from one or many
tables which depends on the written SQL query to create a view.

Views, which are a type of virtual tables allow users to do the following −

 Structure data in a way that users or classes of users find natural or intuitive.

 Restrict access to the data in such a way that a user can see and (sometimes) modify exactly what they
need and no more.

 Summarize data from various tables which can be used to generate reports.

28
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.
In this tutorial, we will cover 4 different types of SET operations, along with example:

1. UNION
2. UNION ALL

3. INTERSECT

4. MINUS

Creating Views
Database views are created using the CREATE VIEW statement. Views can be created from a single table,
multiple tables or another view.

To create a view, a user must have the appropriate system privilege according to the specific implementation.

The basic CREATE VIEW syntax is as follows −

CREATE VIEW view_name AS


SELECT column1, column2.....
FROM table_name
WHERE [condition];
You can include multiple tables in your SELECT statement in a similar way as you use them in a normal SQL
SELECT query.

Example
Consider the CUSTOMERS table having the following records −

+----+----------+-----+-----------+----------+

| ID | NAME | AGE | ADDRESS | SALARY |

+----+----------+-----+-----------+----------+

| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |

| 2 | Khilan | 25 | Delhi | 1500.00 |

| 3 | kaushik | 23 | Kota | 2000.00 |

| 4 | Chaitali | 25 | Mumbai | 6500.00 |

| 5 | Hardik | 27 | Bhopal | 8500.00 |

29
| 6 | Komal | 22 | MP | 4500.00 |

| 7 | Muffy | 24 | Indore | 10000.00 |

+----+----------+-----+-----------+----------+

Following is an example to create a view from the CUSTOMERS table. This view would be used to have
customer name and age from the CUSTOMERS table.

SQL > CREATE VIEW CUSTOMERS_VIEW AS

SELECT name, age

FROM CUSTOMERS;

Now, you can query CUSTOMERS_VIEW in a similar way as you query an actual table. Following is an
example for the same.

SQL > SELECT * FROM CUSTOMERS_VIEW;

This would produce the following result.

+----------+-----+
| name | age |
+----------+-----+
| Ramesh | 32 |
| Khilan | 25 |
| kaushik | 23 |
| Chaitali | 25 |
| Hardik | 27 |
| Komal | 22 |
| Muffy | 24 |
+----------+-----+

The WITH CHECK OPTION


The WITH CHECK OPTION is a CREATE VIEW statement option. The purpose of the WITH CHECK
OPTION is to ensure that all UPDATE and INSERTs satisfy the condition(s) in the view definition.

If they do not satisfy the condition(s), the UPDATE or INSERT returns an error.

The following code block has an example of creating same view CUSTOMERS_VIEW with the WITH
CHECK OPTION.

CREATE VIEW CUSTOMERS_VIEW AS

SELECT name, age

FROM CUSTOMERS

30
WHERE age IS NOT NULL

WITH CHECK OPTION;

The WITH CHECK OPTION in this case should deny the entry of any NULL values in the view's AGE
column, because the view is defined by data that does not have a NULL value in the AGE column.

Updating a View
A view can be updated under certain conditions which are given below −

 The SELECT clause may not contain the keyword DISTINCT.

 The SELECT clause may not contain summary functions.

 The SELECT clause may not contain set functions.

 The SELECT clause may not contain set operators.

 The SELECT clause may not contain an ORDER BY clause.

 The FROM clause may not contain multiple tables.

 The WHERE clause may not contain subqueries.

 The query may not contain GROUP BY or HAVING.

 Calculated columns may not be updated.

 All NOT NULL columns from the base table must be included in the view in order for the INSERT
query to function.

So, if a view satisfies all the above-mentioned rules then you can update that view. The following code block
has an example to update the age of Ramesh.

SQL > UPDATE CUSTOMERS_VIEW

SET AGE = 35

WHERE name = 'Ramesh';

This would ultimately update the base table CUSTOMERS and the same would reflect in the view itself. Now,
try to query the base table and the SELECT statement would produce the following result.

+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 35 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |

31
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+

Inserting Rows into a View


Rows of data can be inserted into a view. The same rules that apply to the UPDATE command also apply to the
INSERT command.

Here, we cannot insert rows in the CUSTOMERS_VIEW because we have not included all the NOT NULL
columns in this view, otherwise you can insert rows in a view in a similar way as you insert them in a table.

Deleting Rows into a View


Rows of data can be deleted from a view. The same rules that apply to the UPDATE and INSERT commands
apply to the DELETE command.

Following is an example to delete a record having AGE = 22.

SQL > DELETE FROM CUSTOMERS_VIEW

WHERE age = 22;

This would ultimately delete a row from the base table CUSTOMERS and the same would reflect in the view
itself. Now, try to query the base table and the SELECT statement would produce the following result.

+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 35 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+

Dropping Views
Obviously, where you have a view, you need a way to drop the view if it is no longer needed. The syntax is
very simple and is given below −

DROP VIEW view_name;


Following is an example to drop the CUSTOMERS_VIEW from the CUSTOMERS table.

DROP VIEW CUSTOMERS_VIEW;

32
SET Operations in SQL

UNION Operation
UNION is used to combine the results of two or more SELECT statements. However it will eliminate duplicate
rows from its resultset. In case of union, number of columns and datatype must be same in both the tables, on
which UNION operation is being applied.

Example of UNION
The First table,

ID Name

1 abhi

2 adam

The Second table,

ID Name

2 adam

3 Chester

Union SQL query will be,


SELECT * FROM First
UNION
SELECT * FROM Second;

33
The resultset table will look like,

ID NAME

1 abhi

2 adam

3 Chester

UNION ALL
This operation is similar to Union. But it also shows the duplicate rows.

Example of Union All


The First table,

ID NAME

1 abhi

2 adam

The Second table,

ID NAME

34
2 adam

3 Chester

Union All query will be like,


SELECT * FROM First
UNION ALL
SELECT * FROM Second;
The resultset table will look like,

ID NAME

1 abhi

2 adam

2 adam

3 Chester

INTERSECT
Intersect operation is used to combine two SELECT statements, but it only retuns the records which are
common from both SELECT statements. In case of Intersect the number of columns and datatype must be
same.
NOTE: MySQL does not support INTERSECT operator.

35
Example of Intersect
The First table,

ID NAME

1 abhi

2 adam

The Second table,

ID NAME

2 adam

3 Chester

Intersect query will be,


SELECT * FROM First
INTERSECT
SELECT * FROM Second;
The resultset table will look like

ID NAME

2 adam

36
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.

Example of Minus
The First table,

ID NAME

1 abhi

2 adam

The Second table,

ID NAME

2 adam

3 Chester

Minus query will be,


SELECT * FROM First
MINUS
SELECT * FROM Second;

37
The resultset table will look like,

ID NAME

1 abhi

RESULT:

Thus Views and Set operators have been successfully executed using SQL.

38
BUILT IN FUNCTIONS
EXP NO: 6

AIM
To execute SQL built in functions

OBJECTIVE

SQL has many built-in functions for performing processing on string or numeric data. Following is the list of
all useful SQL built-in functions −

 SQL COUNT Function - The SQL COUNT aggregate function is used to count the number of rows in a
database table.

 SQL MAX Function - The SQL MAX aggregate function allows us to select the highest (maximum)
value for a certain column.

 SQL MIN Function - The SQL MIN aggregate function allows us to select the lowest (minimum) value
for a certain column.

 SQL AVG Function - The SQL AVG aggregate function selects the average value for certain table
column.

 SQL SUM Function - The SQL SUM aggregate function allows selecting the total for a numeric
column.

 SQL SQRT Functions - This is used to generate a square root of a given number.

 SQL RAND Function - This is used to generate a random number using SQL command.

39
 SQL CONCAT Function - This is used to concatenate any string inside any SQL command.

 SQL Numeric Functions - Complete list of SQL functions required to manipulate numbers in SQL.

 SQL String Functions - Complete list of SQL functions required to manipulate strings in SQL.

PROCEDURE:

SQL SQRT function is used to find out the square root of any number. You can Use SELECT statement to find
out square root of any number as follows −

SQL> select SQRT(16);

+----------+

| SQRT(16) |

+----------+

| 4.000000 |

+----------+

1 row in set (0.00 sec)

You are seeing float value here because internally SQL will manipulate square root in float data type.

You can use SQRT function to find out square root of various records as well. To understand SQRT function in
more detail consider, an employee_tbl, table which is having the following records −

SQL> SELECT * FROM employee_tbl;

+------+------+------------+--------------------+

| id | name | work_date | daily_typing_pages |

+------+------+------------+--------------------+

| 1 | John | 2007-01-24 | 250 |

| 2 | Ram | 2007-05-27 | 220 |

| 3 | Jack | 2007-05-06 | 170 |

40
| 3 | Jack | 2007-04-06 | 100 |

| 4 | Jill | 2007-04-06 | 220 |

| 5 | Zara | 2007-06-06 | 300 |

| 5 | Zara | 2007-02-06 | 350 |

+------+------+------------+--------------------+

7 rows in set (0.00 sec)

Now suppose based on the above table you want to calculate square root of all the dialy_typing_pages, then
you can do so by using the following command −

SQL> SELECT name, SQRT(daily_typing_pages)

-> FROM employee_tbl;

+------+--------------------------+

| name | SQRT(daily_typing_pages) |

+------+--------------------------+

| John | 15.811388 |

| Ram | 14.832397 |

| Jack | 13.038405 |

| Jack | 10.000000 |

| Jill | 14.832397 |

| Zara | 17.320508 |

| Zara | 18.708287 |

+------+--------------------------+

7 rows in set (0.00 sec)

SQL has a RAND function that can be invoked to produce random numbers between 0 and 1 −

SQL> SELECT RAND( ), RAND( ), RAND( );

+------------------+-----------------+------------------+

41
| RAND( ) | RAND( ) | RAND( ) |

+------------------+-----------------+------------------+

| 0.45464584925645 | 0.1824410643265 | 0.54826780459682 |

+------------------+-----------------+------------------+

1 row in set (0.00 sec)

When invoked with an integer argument, RAND( ) uses that value to seed the random number generator. Each
time you seed the generator with a given value, RAND( ) will produce a repeatable series of numbers −

SQL> SELECT RAND(1), RAND( ), RAND( );

+------------------+------------------+------------------+

| RAND(1 ) | RAND( ) | RAND( ) |

+------------------+------------------+------------------+

| 0.18109050223705 | 0.75023211143001 | 0.20788908117254 |

+------------------+------------------+------------------+

1 row in set (0.00 sec)

You can use ORDER BY RAND() to randomize a set of rows or values as follows −

To understand ORDER BY RAND() function, consider an employee_tbltable, which is having the following
records −

SQL> SELECT * FROM employee_tbl;

+------+------+------------+--------------------+

| id | name | work_date | daily_typing_pages |

+------+------+------------+--------------------+

| 1 | John | 2007-01-24 | 250 |

| 2 | Ram | 2007-05-27 | 220 |

| 3 | Jack | 2007-05-06 | 170 |

| 3 | Jack | 2007-04-06 | 100 |

| 4 | Jill | 2007-04-06 | 220 |

| 5 | Zara | 2007-06-06 | 300 |

42
| 5 | Zara | 2007-02-06 | 350 |

+------+------+------------+--------------------+

7 rows in set (0.00 sec)

Now, use the following commands −

SQL> SELECT * FROM employee_tbl ORDER BY RAND();

+------+------+------------+--------------------+

| id | name | work_date | daily_typing_pages |

+------+------+------------+--------------------+

| 5 | Zara | 2007-06-06 | 300 |

| 3 | Jack | 2007-04-06 | 100 |

| 3 | Jack | 2007-05-06 | 170 |

| 2 | Ram | 2007-05-27 | 220 |

| 4 | Jill | 2007-04-06 | 220 |

| 5 | Zara | 2007-02-06 | 350 |

| 1 | John | 2007-01-24 | 250 |

+------+------+------------+--------------------+

7 rows in set (0.01 sec)

SQL> SELECT * FROM employee_tbl ORDER BY RAND();

+------+------+------------+--------------------+

| id | name | work_date | daily_typing_pages |

+------+------+------------+--------------------+

| 5 | Zara | 2007-02-06 | 350 |

| 2 | Ram | 2007-05-27 | 220 |

| 3 | Jack | 2007-04-06 | 100 |

| 1 | John | 2007-01-24 | 250 |

| 4 | Jill | 2007-04-06 | 220 |

43
| 3 | Jack | 2007-05-06 | 170 |

| 5 | Zara | 2007-06-06 | 300 |

+------+------+------------+--------------------+

7 rows in set (0.00 sec)

SQL CONCAT function is used to concatenate two strings to form a single string. Try out the following
example −

SQL> SELECT CONCAT('FIRST ', 'SECOND');

+----------------------------+

| CONCAT('FIRST ', 'SECOND') |

+----------------------------+

| FIRST SECOND |

+----------------------------+

1 row in set (0.00 sec)

To understand CONCAT function in more detail, consider an employee_tbltable, which is having the
following records −

SQL> SELECT * FROM employee_tbl;

+------+------+------------+--------------------+

| id | name | work_date | daily_typing_pages |

+------+------+------------+--------------------+

| 1 | John | 2007-01-24 | 250 |

| 2 | Ram | 2007-05-27 | 220 |

| 3 | Jack | 2007-05-06 | 170 |

| 3 | Jack | 2007-04-06 | 100 |

| 4 | Jill | 2007-04-06 | 220 |

| 5 | Zara | 2007-06-06 | 300 |

| 5 | Zara | 2007-02-06 | 350 |

+------+------+------------+--------------------+

44
7 rows in set (0.00 sec)

Now suppose based on the above table you want to concatenate all the names employee ID and work_date,
then you can do it using the following command −

SQL> SELECT CONCAT(id, name, work_date)

-> FROM employee_tbl;

+-----------------------------+

| CONCAT(id, name, work_date) |

+-----------------------------+

| 1John2007-01-24 |

| 2Ram2007-05-27 |

| 3Jack2007-05-06 |

| 3Jack2007-04-06 |

| 4Jill2007-04-06 |

| 5Zara2007-06-06 |

| 5Zara2007-02-06 |

+-----------------------------+

7 rows in set (0.00 sec)

ABS(X)
The ABS() function returns the absolute value of X. Consider the following example −

SQL> SELECT ABS(2);

+---------------------------------------------------------+

| ABS(2) |

+---------------------------------------------------------+

|2 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

45
SQL> SELECT ABS(-2);

+---------------------------------------------------------+

| ABS(2) |

+---------------------------------------------------------+

|2 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

ACOS(X)
This function returns the arccosine of X. The value of X must range between -1 and 1 or NULL will be
returned. Consider the following example −

SQL> SELECT ACOS(1);

+---------------------------------------------------------+

| ACOS(1) |

+---------------------------------------------------------+

| 0.000000 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

ASIN(X)
The ASIN() function returns the arcsine of X. The value of X must be in the range of -1 to 1 or NULL is
returned.

SQL> SELECT ASIN(1);

+---------------------------------------------------------+

| ASIN(1) |

+---------------------------------------------------------+

| 1.5707963267949 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

46
ATAN(X)
This function returns the arctangent of X.

SQL> SELECT ATAN(1);

+---------------------------------------------------------+

| ATAN(1) |

+---------------------------------------------------------+

| 0.78539816339745 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

CEIL(X)
CEILING(X)
These functions return the smallest integer value that is not smaller than X. Consider the following example −

SQL> SELECT CEILING(3.46);

+---------------------------------------------------------+

| CEILING(3.46) |

+---------------------------------------------------------+

|4 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

SQL> SELECT CEIL(-6.43);

+---------------------------------------------------------+

| CEIL(-6.43) |

+---------------------------------------------------------+

| -6 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

47
ASCII(str)
Returns the numeric value of the leftmost character of the string str. Returns 0 if str is the empty string. Returns
NULL if str is NULL. ASCII() works for characters with numeric values from 0 to 255.

SQL> SELECT ASCII('2');

+---------------------------------------------------------+

| ASCII('2') |

+---------------------------------------------------------+

| 50 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

SQL> SELECT ASCII('dx');

+---------------------------------------------------------+

| ASCII('dx') |

+---------------------------------------------------------+

| 100 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

BIN(N)
Returns a string representation of the binary value of N, where N is a longlong (BIGINT) number. This is
equivalent to CONV(N,10,2). Returns NULL if N is NULL.

SQL> SELECT BIN(12);

+---------------------------------------------------------+

| BIN(12) |

+---------------------------------------------------------+

| 1100 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

48
BIT_LENGTH(str)
Returns the length of the string str in bits.

SQL> SELECT BIT_LENGTH('text');

+---------------------------------------------------------+

| BIT_LENGTH('text') |

+---------------------------------------------------------+

| 32 |

+---------------------------------------------------------+

1 row in set (0.00 sec)

CHAR(N,... [USING charset_name])


CHAR() interprets each argument N as an integer and returns a string consisting of the characters given by the
code values of those integers. NULL values are skipped.

SQL> SELECT CHAR(77,121,83,81,'76');

+---------------------------------------------------------+

| CHAR(77,121,83,81,'76') |

+---------------------------------------------------------+

| MySQL |

+---------------------------------------------------------+

1 row in set (0.00 sec)

CHAR_LENGTH(str)
Returns the length of the string str measured in characters. A multi-byte character counts as a single character.
This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas
CHAR_LENGTH() returns 5.

SQL> SELECT CHAR_LENGTH("text");

+---------------------------------------------------------+

| CHAR_LENGTH("text") |

+---------------------------------------------------------+

|4 |

49
+---------------------------------------------------------+

1 row in set (0.00 sec)

CHARACTER_LENGTH(str)
CHARACTER_LENGTH() is a synonym for CHAR_LENGTH().

CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. May have one or more arguments. If all
arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings,
the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want
to avoid that, you can use an explicit type cast, as in this example −

SQL> SELECT CONCAT('My', 'S', 'QL');

+---------------------------------------------------------+

| CONCAT('My', 'S', 'QL') |

+---------------------------------------------------------+

| MySQL |

+---------------------------------------------------------+

1 row in set (0.00 sec)

50
RESULT:

Thus Built in functions have been successfully executed using SQL.

CURSORS
EXP NO : 7

AIM:

To Execute PLSQL Cursors using SQL

OBJECTIVE:

In this Exercise, we will execute the cursors in PL/SQL. Oracle creates a memory area, known as the context
area, for processing an SQL statement, which contains all the information needed for processing the statement;
for example, the number of rows processed, etc.

51
A cursor is a pointer to this context area. PL/SQL controls the context area through a cursor. A cursor holds
the rows (one or more) returned by a SQL statement. The set of rows the cursor holds is referred to as
the active set.

You can name a cursor so that it could be referred to in a program to fetch and process the rows returned by the
SQL statement, one at a time. There are two types of cursors −

 Implicit cursors
 Explicit cursors

PROCEDURE

CREATE TABLE PRODUCTS(PRODUCTNAME VARCHAR(30),UNITPRICE DECIMAL)


INSERT INTO PRODUCTS VALUES('BOOK',300)
INSERT INTO PRODUCTS VALUES('HARD DISK',6000)
INSERT INTO PRODUCTS VALUES('PENDRIVE',400)
INSERT INTO PRODUCTS VALUES('FLOPPY',700)
SELECT * FROM PRODUCTS

DECLARE CUR_PROD CURSOR


FOR
SELECT PRODUCTNAME, UNITPRICE FROM PRODUCTS
DECLARE
@PNAME VARCHAR(30), @PRICE DECIMAL(8,2)
PRINT 'PRICE PRODUCT'
PRINT '===== ======='
OPEN CUR_PROD
FETCH NEXT FROM CUR_PROD INTO @PNAME, @PRICE
WHILE @@FETCH_STATUS=0
BEGIN
PRINT CONVERT(VARCHAR, @PRICE)+ ' => ' + @PNAME
FETCH NEXT FROM CUR_PROD INTO @PNAME, @PRICE
END
CLOSE CUR_PROD
DEALLOCATE CUR_PROD

52
RESULT:

Thus PL/SQL Cursors have been successfully executed using SQL.

TRIGGERS
EXP NO: 8

AIM:

To Execute PLSQL Triggers using SQL

53
OBJECTIVE:

Triggers are stored programs, which are automatically executed or fired when some events occur. Triggers are,
in fact, written to be executed in response to any of the following events −

 A database manipulation (DML) statement (DELETE, INSERT, or UPDATE)

 A database definition (DDL) statement (CREATE, ALTER, or DROP).

 A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or SHUTDOWN).

Triggers can be defined on the table, view, schema, or database with which the event is associated.

Benefits of Triggers
Triggers can be written for the following purposes −

 Generating some derived column values automatically


 Enforcing referential integrity

 Event logging and storing information on table access

 Auditing

 Synchronous replication of tables

 Imposing security authorizations

 Preventing invalid transactions

Creating Triggers
The syntax for creating a trigger is −

CREATE [OR REPLACE ] TRIGGER trigger_name

{BEFORE | AFTER | INSTEAD OF }

{INSERT [OR] | UPDATE [OR] | DELETE}

[OF col_name]

ON table_name

[REFERENCING OLD AS o NEW AS n]

[FOR EACH ROW]

WHEN (condition)

DECLARE

54
Declaration-statements

BEGIN

Executable-statements

EXCEPTION

Exception-handling-statements

END;

Where,

 CREATE [OR REPLACE] TRIGGER trigger_name − Creates or replaces an existing trigger with
the trigger_name.

 {BEFORE | AFTER | INSTEAD OF} − This specifies when the trigger will be executed. The
INSTEAD OF clause is used for creating trigger on a view.

 {INSERT [OR] | UPDATE [OR] | DELETE} − This specifies the DML operation.

 [OF col_name] − This specifies the column name that will be updated.

 [ON table_name] − This specifies the name of the table associated with the trigger.

 [REFERENCING OLD AS o NEW AS n] − This allows you to refer new and old values for various
DML statements, such as INSERT, UPDATE, and DELETE.

 [FOR EACH ROW] − This specifies a row-level trigger, i.e., the trigger will be executed for each row
being affected. Otherwise the trigger will execute just once when the SQL statement is executed, which
is called a table level trigger.

 WHEN (condition) − This provides a condition for rows for which the trigger would fire. This clause is
valid only for row-level triggers.

PROCEDURE:

CREATE TABLE TECH(TECH_NO INTEGER,NAME VARCHAR(50))


INSERT INTO TECH VALUES(11,'NAVEEN')
INSERT INTO TECH VALUES(12,'JACKSON')
SELECT*FROM TECH

55
CREATE TRIGGER TRG1 ON TECH FOR UPDATE
AS
PRINT 'ONE ROW UPDATED'

DROP TRIGGER TRG1

CREATE TRIGGER TRG2 ON TECH FOR UPDATE


AS
IF UPDATE(TECH_NO)
RAISERROR('CANNOT MODIFY',1,1)
ROLLBACK TRANSACTION

UPDATE TECH SET TECH_NO=12 WHERE NAME='NAVEEN'

DROP TRIGGER TRG2

RESULT:

Thus PL/SQL Triggers have been successfully executed using SQL.

56
ROLES AND PRIVILEGES
EXP NO : 9

AIM:

To Execute roles and privileges using SQL

OBJECTIVE:

DCL commands are used to enforce database security in a multiple user database environment. Two types of
DCL commands are GRANT and REVOKE. Only Database Administrator's or owner's of the database object
can provide/remove privileges on a database object.

SQL GRANT Command


SQL GRANT is a command used to provide access or privileges on the database objects to the users.
The Syntax for the GRANT command is:
GRANT privilege_name
ON object_name
TO {user_name |PUBLIC |role_name}
[WITH GRANT OPTION];
 privilege_name is the access right or privilege granted to the user. Some of the access rights are
ALL, EXECUTE, and SELECT.
 object_name is the name of an database object like TABLE, VIEW, STORED PROC and
SEQUENCE.
 user_name is the name of the user to whom an access right is being granted.
 user_name is the name of the user to whom an access right is being granted.
 PUBLIC is used to grant access rights to all users.
 ROLES are a set of privileges grouped together.
 WITH GRANT OPTION - allows a user to grant access rights to other users.
For Example: GRANT SELECT ON employee TO user1; This command grants a SELECT permission on
employee table to user1.You should use the WITH GRANT option carefully because for example if you
GRANT SELECT privilege on employee table to user1 using the WITH GRANT option, then user1 can
GRANT SELECT privilege on employee table to another user, such as user2 etc. Later, if you REVOKE
the SELECT privilege on employee from user1, still user2 will have SELECT privilege on employee table.
SQL REVOKE Command:
The REVOKE command removes user access rights or privileges to the database objects.
The Syntax for the REVOKE command is:
REVOKE privilege_name
ON object_name
FROM {user_name |PUBLIC |role_name}
For Example: REVOKE SELECT ON employee FROM user1;This command will REVOKE a SELECT
privilege on employee table from user1.When you REVOKE SELECT privilege on a table from a user, the
user will not be able to SELECT data from that table anymore. However, if the user has received SELECT

57
privileges on that table from more than one users, he/she can SELECT from that table until everyone who
granted the permission revokes it. You cannot REVOKE privileges if they were not initially granted by
you.

PROCEDURE:

testdb=# CREATE USER manisha WITH PASSWORD 'password';

CREATE ROLE

The message CREATE ROLE indicates that the USER "manisha" is created.

Consider the table COMPANY having records as follows −

testdb# select * from COMPANY;

id | name | age | address | salary

----+-------+-----+-----------+--------

1 | Paul | 32 | California| 20000

2 | Allen | 25 | Texas | 15000

3 | Teddy | 23 | Norway | 20000

4 | Mark | 25 | Rich-Mond | 65000

5 | David | 27 | Texas | 85000

6 | Kim | 22 | South-Hall| 45000

7 | James | 24 | Houston | 10000

(7 rows)

Next, let us grant all privileges on a table COMPANY to the user "manisha" as follows −

testdb=# GRANT ALL ON COMPANY TO manisha;

GRANT

The message GRANT indicates that all privileges are assigned to the USER.

Next, let us revoke the privileges from the USER "manisha" as follows −

testdb=# REVOKE ALL ON COMPANY FROM manisha;

58
REVOKE

The message REVOKE indicates that all privileges are revoked from the USER.

You can even delete the user as follows −

testdb=# DROP USER manisha;

DROP ROLE

The message DROP ROLE indicates USER ‘Manisha’ is deleted from the database.

RESULT:

Thus Roles and Privileges have been successfully executed using SQL.

59
PL/SQL PROGRAMMING
EXP NO : 10

AIM:

To Execute PL/SQL programs SQL

OBJECTIVE:

PL/SQL is a combination of SQL along with the procedural features of programming languages. It was
developed by Oracle Corporation in the early 90's to enhance the capabilities of SQL. PL/SQL is one of three
key programming languages embedded in the Oracle Database, along with SQL itself and Java. This tutorial
will give you great understanding on PL/SQL to proceed with Oracle database and other advanced RDBMS
concepts.

PROCEDURE:

10.A) FIBONACCI SERIES

DECLARE @X INT
DECLARE @Y INT
DECLARE @FIB INT

SET @X=0
SET @Y=1
SET @FIB=0

PRINT @X
PRINT @Y

WHILE @FIB<100
BEGIN
SET @FIB=@X+@Y
PRINT @FIB
SET @X=@Y
SET @Y=@FIB
END

Output:

60
10.B). SUM OF N NATURAL NUMBERS
DECLARE @A INT=0
DECLARE @B INT=1
DECLARE @C INT=10
WHILE @B<=@C
BEGIN
SET @A=@A+@B
SET @B=@B+1
END
PRINT @A

Output:

61
10.C) REVERSE OF A GIVEN NUMBER

DECLARE @NO INT


DECLARE @REV INT=0
SET @NO=123;
PRINT 'ENTERED NUMBER'
PRINT @NO
WHILE (@NO>0)
BEGIN
SET @REV=@REV*10+@NO%10
SET @NO=CEILING(@NO/10)
END
PRINT 'REVERSE NUMBER'
PRINT @REV

Output:

10.D) FACTORIAL OF A GIVEN NUMBER

DECLARE @NUM INT=5


DECLARE @I INT=1
DECLARE @F INT=1
WHILE @I<=@NUM
BEGIN
SET @F=@F*@I
SET @I=@I+1
END
PRINT 'THE FACTORIAL OF 5 IS: '
PRINT @F

Output:

RESULT:

Thus PL/SQL programs have been successfully executed using SQL.

62
MINI PROJECT
EXP NO: 11

In this experiment, Students are allowed to develop an application by using SQL as backend, and choice
of the frontend is left to the student.

RESULT:

The results are successfully examined and demonstrated.

63
VIVA Q & A

1. Define database management system?


Database management system (DBMS) is a collection of interrelated data and a set of programs to access
those data.

2. Explain the two types of participation constraint.


Total: The participation of an entity set E in a relationship set R is said to be total if every entity in
E participates in at least one relationship in R.
Partial: if only some entities in E participate in relationships in R, the participation of entity set E in
relationship R is said to be partial.

3. Define the terms i) DDL ii) DML


DDL: Data base schema is specified by a set of definitions expressed by a special language called a data
definition language.
DML: A data manipulation language is a language that enables users to access or manipulate data as
organized by the appropriate data model.

4. Define tuple and attribute


Attributes: column headers
Tuple : Row

5. Define the term relation.


Relation is a subset of a Cartesian product of list domains.

6.What is a candidate key?


Minimal super keys are called candidate keys.

7. What is a primary key?


Primary key is chosen by the database designer as the principal means of identifying an entity in the entity
set.

8.What is a super key?


A super key is a set of one or more attributes that collectively allows us to identify uniquely an entity in the
entity set.

9.Define query language?


A query is a statement requesting the retrieval of information. The portion of DML that involves information
retrieval is called a query language.

10.What is foreign key?


A relation schema r1 derived from an ER schema may include among its attributes the primary key of
another relation schema r2.this attribute is called a foreign key from r1 referencing r2.

11.What are the three classes of SQL expression?

64
SQL expression consists of three clauses:
Select
From
Where
12.List the set operations of SQL?
Union
Intersect operation
The except operation

13.What is the use of Union and intersection operation?


Union : The result of this operation includes all tuples that are either in r1 or in r2 or in both r1 and
r2.Duplicate tuples are automatically eliminated.
Intersection: The result of this relation includes all tuples that are in both r1 and r2.

14. What are aggregate functions? And list the aggregate functions supported by
SQL?
Aggregate functions are functions that take a collection of values as input and return a single value.
Aggregate functions supported by SQL are
Average: avg
Minimum: min
Maximum: max
Total: sum
Count: count

15. What is the use of group by clause?


Group by clause is used to apply aggregate functions to a set of tuples. The attributes given in the group by
clause are used to form groups. Tuples with the same value on all attributes in the group by clause are
placed in one group.

16. What is the use of sub queries?


A sub query is a select-from-where expression that is nested with in another query. A common use of sub
queries is to perform tests for set membership, make set comparisons, and determine set cardinality.

17. What is view in SQL? How is it defined?


Any relation that is not part of the logical model, but is made visible to a user as a virtual relation is called a
view.
We define view in SQL by using the create view command. The form of the create view command is
Create view v as <query expression>

18.List the table modification commands in SQL?


Deletion
Insertion
Updates
Update of a view

19.List the SQL domain Types?


SQL supports the following domain types.
Char(n) 2) varchar(n) 3) int 4) numeric(p,d)
5) float(n) 6) date.

65
20.What is the use of integrity constraints?
Integrity constraints ensure that changes made to the database by authorized users do not result in a loss of
data consistency. Thus integrity constraints guard against accidental damage to the database.

21.What is trigger?
Triggers are statements that are executed automatically by the system as the side effect of a modification to
the database.

22.What is trigger?
Triggers are statements that are executed automatically by the system as the side effect of a modification to
the database.

23.Name the various privileges in SQL?


Delete
Select
Insert
Update

24.Explain DML, DDL, DCL and TCL statements with examples?


DML: DML stands for Data Manipulation Language. DML is used to retrieve, store, modify, delete, insert
and update data in database.
Examples of DML statements: SELECT, UPDATE, INSERT, DELETE statements.

DDL: DDL stands for Data Definition Language. DDL is used to create and modify the structure of
database objects.
Examples: CREATE, ALTER, DROP statements.

DCL: DCL stands for Data Control Language. DCL is used to create roles, grant and revoke permissions,
establish referential integrity etc.
Examples: GRANT, REVOKE statements

TCL: TCL stands for Transactional Control Language. TCL is used to manage transactions within a
database.
Examples: COMMIT, ROLLBACK statements

25. What is the difference between Drop, Delete and Truncate statements in SQL Server?
Drop, Delete and Truncate - All operations can be rolled back.

Delete is a logged operation, which means deleted rows are written to the transaction log.Truncate is not a
logged operation, which means deleted rows are not written to the transaction log.

Hence, truncate is a little faster than Delete. You can have a where clause in Delete statement where as
Truncate statement cannot have a where clause. Truncate will delete all the rows in a Table, but the structure
of the table remains. Drop would delete all the rows including the structure of the Table.

26. DIfference between primary key and unique key in SQL Server?
1. A table can have only one primary key. On the other hand a table can have more than one unique key.

66
2. Primary key column does not accept any null values, where as a unique key column accept one null value.

27. What is the difference between Having and Where clause?


a WHERE clause is used in the select statement to filter the rows as they are retrieved from the database
table. HAVING clause is used in the select statement in conjunction with the Group By clause, to filter the
query results after they have been grouped.
You can use HAVING clause only when you use Group By clause.

28. What is RDBMS?


Relational Data Base Management Systems (RDBMS) are database management systems that maintain data
records and indices in tables. Relationships may be created and maintained across and among the data and
tables. In a relational database, relationships between data items are expressed by means of tables.
Interdependencies among these tables are expressed by data values rather than by pointers. This allows a
high degree of data independence. An RDBMS has the capability to recombine the data items from different
files, providing powerful tools for data usage.

29.What is View?
A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating
or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was
created with. It should also be noted that as data in the original table changes, so does data in the view, as
views are the way to look at part of the original table. The results of using a view are not permanently stored
in the database. The data accessed through a view is actually constructed using standard T-SQL select
command and can come from one to many different base tables or even other views.

30.What is cursors?
Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis, instead of
the typical SQL commands that operate on all the rows in the set at one time.

In order to work with a cursor we need to perform some steps in the following order:
Declare cursor
Open cursor
Fetch row from the cursor
Process fetched row Close cursor
Deallocate cursor

31. What is the difference between SQL and PL/SQL?


PL/SQL is a dialect of SQL that adds procedural features of programming languages in SQL. It was
developed by Oracle Corporation in the early 90's to enhance the capabilities of SQL.
What are various DCL commands in SQL? Give brief description of their purposes.
Following are various DCL or Data Control Language commands in SQL −

GRANT − it gives a privilege to user.

REVOKE − it takes back privileges granted from user.


32.Is a NULL value same as zero or a blank space? If not then what is the difference?
A NULL value is not same as zero or a blank space. A NULL value is a value which is ‘unavailable,
unassigned, unknown or not applicable’. Whereas, zero is a number and blank space is a character.

67
33. If a table contains duplicate rows, does a query result display the duplicate values by default? Ho
can you eliminate duplicate rows from a query result?
A query result displays all rows including the duplicate rows. To eliminate duplicate rows in the result, the
DISTINCT keyword is used in the SELECT clause.
What is the default ordering of data using the ORDER BY clause? How could it be changed?
The default sorting order is ascending. It can be changed using the DESC keyword, after the column name
in the ORDER BY clause.
34.What is the difference between cross joins and natural joins?
The cross join produces the cross product or Cartesian product of two tables. The natural join is
based on all the columns having same name and data types in both the tables.
35. Say True or False. Give explanation if False.
COUNT(*) returns the number of columns in a table.

False. COUNT(*) returns the number of rows in a table.


What’s wrong in the following query?

SELECT subject_code, count(name)

FROM students;

It doesn’t have a GROUP BY clause. The subject_code should be in the GROUP BY clause.

SELECT subject_code, count(name)

FROM students

GROUP BY subject_code;

36. Say True or False. Give explanation if False.


A multiple row subquery returns more than one row from the inner SELECT statement.

True.
37.What is the pupose of DML statements in SQL?
The DML statements are used to add new rows to a table, update or modify data in existing rows, or remove
existing rows from a table.
38. What happens if you omit the WHERE clause in the UPDATE statement?
All the rows in the table are modified.

68

S-ar putea să vă placă și