Exp 3 Part 1
Exp 3 Part 1
3 (a) TITLE: CREATING TABLES, INSERT INTO TABLES & SELECT FROM TABLES
View definition-
The SQL DDL includes commands for defining views.
Transaction Control- SQL includes for specifying the beginning and ending of transactions.
Integrity-
The SQL DDL includes commands for specifying integrity constraints that the data stored in the
database must specify. Updates that violate integrity constraints are allowed.
Authorization-
The SQL DDL includes commands for specifying access rights to relations and views.
The SQL DDL allows specification of not only a set of relations but also information about each
relation, including-
Schema for each relation
The domain of values associated with each attribute.
The integrity constraints.
The set of indices to be maintained for each relation.
The security and authorization information for each relation.
The physical storage structure of each relation on disk.
Syntax-
Create table tablename (columnname datatype(size), columnname datatype(size));
Syntax-
INSERT INTO tablename
[(columnname, columnname, ………)] Values(expression, expression);
Syntax-
INSERT INTO tablename
SELECT columnname, columnname, …….
FROM tablename;
Syntax-
INSERT INTO tablename
SELECT columnname, columnname……..
FROM tablename
WHERE columnname= expression;
Retrieving of data from the tables-
Syntax-
SELECT * FROM tablename;
Syntax-
SELECT columnname, columnname, ….
FROM tablename;
Syntax-
SELECT DISTINCT columnname, columnname
FROM tablename;
Syntax-
3(b) TITLE: DATA MANIPULATION LANGUAGE
3.2 THEORY AND CONCEPTS: DML (Data Manipulation Language) Data manipulation is
Deletion Operation:-
A delete request is expressed in much the same way as query. We can delete whole tuple (rows) we
can delete values on only particulars attributes.
Syntax:
Delete from tablename;
+ Addition - Subtraction
* Multiplication ** exponentiation
/ Division () Enclosed operation
Renaming columns used with Expression Lists: - The default output column names can be renamed
by the user if required
Syntax:
Select column name result_columnname,
Columnname result_columnname,
From table name;
Logical Operators:
The logical operators that can be used in SQL sentenced are
Pattern Searching:
The most commonly used operation on string is pattern matching using the operation ‘like’ we
describe patterns by using two special characters.
Percent (%) ; the % character matches any substring we consider the following examples.
‘Perry %’ matches any string beginning with perry
‘% idge % matches any string containing’ idge as substring.
‘ - - - ‘ matches any string exactly three characters.
‘ - - - % matches any string of at least of three characters.
Oracle functions:
Functions are used to manipulate data items and return result. Function follow the format of function
_name (argument1, argument2 ..) .An arrangement is user defined variable or constant. The structure
of function is such that it accepts zero or more arguments.
Examples:
i) Avg: return average value of n
Syntax: Avg ([distinct/all]n)
ii) Min: return minimum value of expr.
Syntax: MIN((distict/all )expr)
iii) Count: Returns the no of rows where expr is not null
Syntax: Count ([distinct/all)expr]
iv) Count (*): Returns the no rows in the table, including duplicates and those with nulls.
v) Max: Return max value of expr
Syntax:
Max ([distinct/all]expr)
vi) Sum: Returns sum of values of n
Syntax: Sum ([distinct/all]n)