3 RDBMS
3 RDBMS
UNIT – III
STRUCTURE QUERY LANGUAGE (SQL)
Q1) What is SQL ? Write the different data types available in SQL.
Ans) E.F.Codd developed the relational model of data base in 1970 . Basing on this relational
model Raymond.F.Boyce developed the SQL language at IBM . SQL is a Database Language
used in RDBMS platform.
Different versions of Oracle are released such as Oracle 10, Oracle 11 etc.
Ans) Data type refers to the type of that a field is storing. For example NUMBER,TEXT,DATE
etc. SQL provides the following data types :
Ans) SQL commands are used to communicate with the database to perform specific task.
1
Q3) Explain DDL command in detail .
DDL - These SQL commands are used to create, alter, drop and truncate the table structure.
(COL NAME1 DATA TYPE SIZE, COL NAME2 DATA TYPE SIZE );
EXAMPLE:
SYNTAX :
ALTER TABLE <TABLE NAME> ADD (COL NAME DATA TYPE SIZE)
EXAMPLE:
SYNTAX :
ALTER TABLE <TABLE NAME> MODIFY (COL NAME DATA TYPE SIZE)
EXAMPLE:
SYNTAX :
EXAMPLE:
2
TRUNCATE This command is used to remove all the records of a table
SYNTAX :
EXAMPLE:
Ans) DML commands are used to Insert. Delete, Update and Select records from the table.
SYNTAX :
EXAMPLE :
SYNTAX :
EXAMPLE :
SYNTAX :
EXAMPLE :
3
DELETE This command is used to delete records
SYNTAX :
EXAMPLE :
DCL These commands are used to control the database . Giving different grants and
permissions to the user comes in this category. Generally these are used in Network
environment.
SYNTAX :
EXAMPLE-1 :
EXAMPLE-2:
EXAMPLE-3
SYNTAX :
EXAMPLE :
4
Q 6) Explain TCL command so SQL
SYNTAX:
COMMIT
ROLLBACK: This command is used to restore the database to last committed state.
SYNTAX:
ROLLBACK
SAVEPOINT: This command is used to create a point to roll back to that point in future.
SYNTAX:
SAVEPOINT Y
Ans) An operator manipulates individual data items and returns a result. The data items are
called as operands.
. 1. ARITHMETIC OPERATOR
2. RELATIONAL OPERATOR
3. LOGICAL OPERATOR
5
Q8) Write about Aggreegate functions of SQL.
6
Q 10) Explain joins . Write about different types of joins in SQL.
Ans) In SQL joins are used to combine tables. In join columns are two tables are joined with a
common key.
1. INNER JOIN
2.LEFT JOIN
3.RIGHT JOIN
4.FULL JOIN
INNER JOIN : This is called as a simple join. Inner join returns all the rows of two tables
where the joint conditions are met.
EXAMPLE:
NOTE: Retrieves data from both tables where the condition is satisfied.
LEFT JOIN: Returns all the rows of left tables and only rows of right table which meet the
Condition.
7
.
EXAMPE:
NOTE: Retrieves all the records of left table STATE and only the matching records of
CITY table
RIGHT JOIN : Returns all the rows of right table and only rows of left side table which
meets the condition.
EXAMPE:
NOTE: Retrieves all the records of right table CITY and only the matching records of
STATE table
8
FULL JOIN : Returns all the rows of both the table and inserting null values where the
condition is not met.
EXAMPE:
NOTE: Retrieves all the records of both STATE & CITY tables irrespective of the
condition.
Q 11) Explain view table. Write different operations performed on view table.
Ans) A view table is not stored in memory . It is not physicaly present. A view is created to
display some of the fields of the table or to see the changes in a table if anything is modified or
updated. This is a virtual or imaginary table only for the display purpose. A view can be created
from one or more tables. To create a view table the user must have the appropriate system
privilege .
9
CREATE VIEW
EXAMPLE
UPDATE VIEW
DELETE VIEW
---------END----------
10