Dbms Assignment 1
Dbms Assignment 1
Database managcment has evolved from a specialized computer application to a central component
Software Required:
1. VB, ORACLE and/or DB2
2. VB, MSACCESS
3. ORACLE, D2K
Hardware Required
Processor: Pentium II
RAM: 128 MB
Hard Disk: 40 GB
Authorization-
rights to relations and views.
The SQL DDL includes commands for specifying access
Page 5
Lab
PCS 503 Database Management system
Schema for cach relation
The domain of values associated with cach attribute.
Int-An integer.
Small integer- A small integer.
Numeric (p. d)-A Fixed point number with user defincd precision.
R e a l . double precision- Floating point and double precision floating point numbers with
Time The time of day, in hours, minutes and seconds Eg. Time '09:30:00.
.Number- Number is used to store numbers (fixed or floating point).
Syntax
Create table tablename (columnname dalatypc(sizc), columnname datatype(size));
Syntax-
CREATE TABLE TABILENAME
(columnname, columnname, . .
AS SELECT columnname, columnnam.FROM tablename;
lab Page 6
PCS S03 Database Management System
Insertion of data inte tables-
Syntax
INSERT INTO tablenume
l(columnname, columnname,. . )
Values(expression, expression);
Syntax-
INSERT INTO tablename
SELECT columnname, columnname,..
FROM tablename;
Syntax-
INSERT INTO tablename
SELECT columnname, columnname...
FROM tablename
Syntax
SELECT FROM tablename;
The retrieving of spccifie columns from a table
Syntax
SELECTcolumnname, columnname,..
FROM tablename;
Elimination of duplicates from the selcet statement-
Syntax-
SELECT DISTINCT columnname, columnname
FROM tablename
WHERE scarchcondition;
pes.
(i)Proccdural DML:i- require a user to specity what data are needed and how to get thosc dala.
(i)Non Procedural DML: require a user to specify what data are needed without specifying how
to get those data.
Updating the content of a table: In creation situation we may wish to change a value in table
without changing all values in the tuple. IFor this purpose the update statement can be used.
Deletion Operation:
A delete query 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:
Syntax:
Delete from table namec
Where scarch condition;
Page 10
PCS 503 Database Management System Lab
Computation in cxpression lists used to select data
+Addition - Subtraction
multiplication * exponentiation
/ Division Enclosed opera
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
Range Searching:
Between operations is used for range searching.
Pattern Searching:
The most used operation on string is paltern matching using the operation "like' we describe
Percent (%); the % character matches any substring we consider the following examples.
with pery
.Perry 6' matches any string beginning
. % idge % matches any string containing' idge as substring.
Lab Page 11
PCS 503 Database Management System
matches any string exactly three characters.
% matches any string of at least of three eharacters.
Oracle funetions:
Functions are used to manipulate data items and relurn result. function follow the format of
function name (argunentl, argument2 .). An arrangement is user delincd variable or constant.
The structure
offunetion is such that it accepts zero or more arguments.
Examples:
Avg Telurn average value oln
Syntax:
Avg (ldistinct/all]n)
Syntax:
MIN((distinc/all )expr)
Syntax:
Count ([distinct/all expr]
Count () Returns the no rows in the table, incuding duplicates and
those with nulls.
Max Relurn max value of expr
Syntax:
Max (distinct/allJexpr)
Syntax:
Sum ([distinc/allin)