Professional Documents
Culture Documents
DBMS Lab Report
DBMS Lab Report
Click Next again and on the next window, type the desired username with a
strong password.
Choose the location and character set and character set, and give a global
database name and password and press next.
CREATE:
This command creates a new table and ahs a predefined syntax. Its syntax is:
CREATE TABLE [TABLE NAME] ([column definitions]) [table parameters];
ALTER:
The ALTER command modifies an existing database table. This command can add
up additional column, drop ones that already exist and even change the data type
of columns involved in a database table.
The syntax of ALTER command is:
ALTER object type object name parameters;
DROP:
DROP command is used to delete objects such as a table index or a view. DROP
statement cannot be rolled back, so once an object is destroyed there is no way
to recover or restore it.
It’s syntax is:
DROP object type object name;
LAB 3: DATA MANIPULATION LANGUAGE (INSERT, UPDATE, DELETE)
Data manipulation language is the type of language that permits the user to
change or manipulate the data in the database. Data manipulation includes
inserting data into the database, retrieving the data from existing database,
deleting data of the existing database as well as modifying the data of existing
database. DML is mostly incorporated in SQL databases. Commands like UPDATE,
INSERT INTO and DELETE FROM as given below:
1) INSERT : The insert command is used to add one or more records into the
database table. The syntax for INSERT command is: INSERT INTO [table name]
[column(s)] VALUES [value(s)].
a) Inserting single record:
3) DELETE: The DELETE command id used to remove one or more than one
records from the table based on the specified condition. The syntax for DELETE
command is: DELETE FROM [table name] where [condition]
LAB 4: DATABASE QUERY LANGUAGE (SELECT, WHERE)
The Oracle statement is used to extract records from one or more than one tables
at once in an Oracle database. The syntax for SELECT statement in Oracle is:
SELECT expression FROM table(s) [WHERE conditions];
Here, Expressions are the columns that you wish to retrieve. * can be used if the
database user wishes to select all columns.
Tables are where the records are retrieved from. At least one table must be listed
in the FROM clause.
Where is the condition, that must be met for the records to be selected from the
table(s) . If no conditions are provided all records will be selected.
Example: create a table customer with attributes (cid, cname, caddress, age) and
insert assumed values.
Select and from clause:
Details of customer of age between 20 and 35
.
Select all fields.
1) Equality operator:
Find all customer who are aged 28.
2) Inequality operator:
Find all customers whose age is not 28.
3) Comparison operator(<,>):
Find customer whose age is less 30 and greater than 20.
4) Between operator:
Find the customers with age between 25 and 45.
5) Like operator:
Find customer whose name starts with B.
6) In operator:
Find age and address of customer named maya and kalu.
LAB 6: JOINS IN ORACLE:
Join is a binary operation that lets a database user to cobine two or more tables
into one.
There are 4 different types of joins:
(1) INNER JOIN (also called simple join)
(2) LEFT OUTER JOIN ( sometimes called left join)
(3) RIGHT OUTER JOIN ( sometimes called right join)
(4) FULL OUTER JOIN ( sometimes called full join)
INNER JOIN (simple join):
This is the most commonly used type of join. It returns all rows from multiple
tables where the join condition is fulfilled. The syntax for inner join is:
SELECT columns FROM table 1 INNER JOIN table 2
ON table1.column=table2.column.
The shaded area of the diagram below is the result of inner join or in other words
the intersection of table 1 and table 2.
For example: we have two tables with the following details
GROUP BY:
The GROUP BY clause is used with select statement to collect data from multiple
records and group the results by one or more columns.
SYNTAX:
SELECT expression1, expression2, ... expression n,
aggregate function (aggregate expression)
FROM tables
WHERE conditions
GROUP BY expression1, expression2, ... expression n;
Consider the table: