0% found this document useful (0 votes)
4 views

Jyot DBMS

Uploaded by

hamiscam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Jyot DBMS

Uploaded by

hamiscam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

1|Page

CERTIFICATE

BTCS402 20BT04035- Jyot Patel


2|Page

This is to certify that the work entered in this laboratory journal is the work of

Ms. /Mr. Jyot Patel of 2nd Year CSE., Discipline B-Tech CSE, Enrollment No. 20BT04035

and has satisfactorily completed the required number of experiments for the 4th Semester,

Academic Year Jan – 2022 in the CSE Laboratory as laid down by the University.

Date:___________________ Course In-Charge

BTCS402 20BT04035- Jyot Patel


3|Page

PREFACE
Computer science and engineering is a branch of engineering that
integrates several fields of computer science and electronic engineering required
to develop computer hardware and software.. Thus, it is important that students
of Computer science and engineering perform experiments in the laboratory to
gain insights and develop understanding of the theories underlying various
phenomenons. Laboratory experimentation allows students the opportunity to
develop techniques and other manipulative skills that students of
engineering must master.
GSFC University understands the importance of laboratory work in the study of
Computer science and engineering. The institute is committed to this component
of your education and hopes that you will take full advantage of this opportunity
to explore the Computer science and engineering.
This laboratory manual is not only a source to enhance your understanding of
Computer science and engineering, but also to utilize, analyze and interpret the
experimental data. It is important that you carefully prepare for each experiment
by reading the related text material before coming to the laboratory in order to
maximize the laboratory experience.
A unique aspect of this laboratory program is that a concerted effort has
been made to use of different language in concept of computer science and
engineering in the experiments. The aim is to not only teach students but also to
lessen the impact of this program upon the real time application. This manual is
free for non–commercial use. All rights reserved. This is brought to you by GSFC
University. It is the user’s responsibility to ensure that proper supervision is
maintained at all times by an appropriately trained person or persons to ensure
the safety of all people using any of the experiments contained in this manual.
Finally, we hope you find this laboratory manual helpful in study of Computer
science and engineering.

BTCS402 20BT04035- Jyot Patel


4|Page

BTCS402 20BT04035- Jyot Patel


5|Page

RECORD OF WORK DONE

Sr. Title Of Experiment Start End Page Signature


No Date Date No
1 Create tables in SQL Command Line. 01-02- 08-02- 7
2022 2022
2 Insert data into tables in SQL Command Line 09-02- 17-02- 10
2022 2022
3 Demonstrate use of DDL commands with an 16-02- 23-02- 13
appropriate example of applying it on a 2022 2022
table.
Explain use of following DDL commands.
1) Create
2) Alter
3) Drop
4) Truncate
5) Rename
Mention query for each command and attach
output of the same.
4 Describe use of following SQL constraint by 22-02- 01-03- 18
applying it on appropriate table. 2022 2022
1) Not Null
2) Unique
5 Describe use of following SQL constraint by 02-03- 07-02- 21
applying it on appropriate table. 2022 2022
1) Check
2) Primary Key
6 Describe use of following SQL constraint by 09-03- 15-03- 23
applying it on appropriate table. 2022 2022
1) Foreign Key
Also show the use of following DML
command.
1) Insert (syntax to insert value of specific
number of columns, making script out of
insert statement to insert values)
7 Describe use of following DDL and DML 16-03- 23-03- 25
commands with appropriate example. 2022 2022
1) Update
2) Delete
3) Drop
4) Truncate
5) Merge

BTCS402 20BT04035- Jyot Patel


6|Page

8 Describe use of following TCL commands 01-04- 04-04- 27


with appropriate example. 2022 2022
1) Commit
2) Savepoint
3) Rollback
9 Describe use of following Oracle SQL 05 - 0 4 12 - 0 4 28
Functions with appropriate example. -2022 -2022
1) Character Functions
2) Number Functions
3) Date Functions
10- Describe various options available with Oracle Date SQL Functions with 18 -04 25 -04 - 30
A appropriate example. -2022 2022

10- Describe use of Null Value Handing Oracle 20 - 0 4 27 -04 - 32


B SQL Functions, SQL Views, Creating Users -2022 2022
and DCL commands with appropriate
example.
11 Create and execute a TRIGGER, PROCEDURE and FUNCTION on a table 29 -04 06 -05 - 36
in SQL. -2022 2022
12 Create and execute a TRIGGER, PROCEDURE and FUNCTION on a table 10 -05 10 -05 - 39
in SQL. -2022 2022
13 Demonstrate the concept of SUBQUERY in SQL. 18-05- 18-05- 42
2022 2022

BTCS402 20BT04035- Jyot Patel


7|Page

Practical-1
Aim:- Create Database using SQL command line.
Description: - In this, we have to make a table using SQL command Line.
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.
Implementation: - First we have to download the Oracle XE 11g version then install it. When you
install in that you have to enter password. This password is remember for the further work. When
your Installation completed then you have to just open SQL command line then simply written
command “conn sys as sysdba” then enter your password(jyotnpatel) which you have entered in
installation. After this you connected with your database. As you can see in the Fig-1.1. After the
connected with database simply do create table in command. And write query for creating table for
DEPOSIT. As you can seen in Fig-1.2. After that you can create BRANCH, CUSTOMERS, BORROW as
you can seen in Fig-1.3, Fig-1.4, Fig-1.5.

SCREENSHOTS

Fig-1.1

Fig-1.2

Fig-1.3

BTCS402 20BT04035- Jyot Patel


8|Page

Fig-1.4

Fig-1.5

Fig-1.6

Fig-1.7

Fig-1.8

Fig-1.9

BTCS402 20BT04035- Jyot Patel


9|Page

Practical-2
Aim:- Insert given data in database table.
Description: - In this, we have to insert the given data in the previously made tables .
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.
Implementation: -First connect your database and then open the previously created table and now
run insert query to insert the given data . As you can see in the Fig-1.1. has insert query for deposit
data and inserted values shown in table.
Fig-1.2 has insert query for branch data and inserted values shown in table.
Fig-1.3 and 1.4 has inserte query for customer data and inserted values shown in table.
Fig-1.5 has insert query for borrow and inserted values shown in table.

Screenshots

Fig-1.1

BTCS402 20BT04035- Jyot Patel


10 | P a g e

Fig-1.2

Fig-1.3

BTCS402 20BT04035- Jyot Patel


11 | P a g e

Fig-1.4

BTCS402 20BT04035- Jyot Patel


12 | P a g e

Practical-3
Aim:- Demonstrate use of DDL commands with an appropriate example of applying it on a

table.
Description: - Explain use of following DDL commands.
1) Create
2) Alter
3) Truncate
4) Rename
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.
Implementation: -

 First we have to connect to conn system and using create query table will be created
as shown in fig-3.1.
 If you want to create table and same structure as you make in previous table then simply
you have to written another create query as shown in Fig-3.2.
 Now if you want to create table as you make in previous table and you want only some
specific columns then you have to written also another create query as shown in Fig-3.3.
 So first in alter we add one specific column as shown in Fig-3.4. After that you can remove or
drop specific column in table as shown in Fig-3.5.
 Now let’s go the fourth command that is TRUNCATE. In this let’s take some data and when
you use truncate it removes all rows from an existing table as shown in Fig-3.6. You can also
use DROP TABLE command to delete complete table but it would remove complete table
structure from the database.
 Now let’s go the fifth command that is RENAME. In this we can change table name using two
methods, first is using alter command and second is RENAME command.
 First, we will take alter command for changing table name as shown in Fig-3.7.
 Second, we will take RENAME command for changing table name as shown in Fig-3.8.

BTCS402 20BT04035- Jyot Patel


13 | P a g e

Fig-3.1

Fig-3.2

Fig-3.3

BTCS402 20BT04035- Jyot Patel


14 | P a g e

Fig-3.4

Fig-3.5

BTCS402 20BT04035- Jyot Patel


15 | P a g e

Fig-3.6

Fig-3.7

BTCS402 20BT04035- Jyot Patel


16 | P a g e

Fig-3.8

BTCS402 20BT04035- Jyot Patel


17 | P a g e

Practical-4
Aim:- Describe use of following SQL constraint by applying it on appropriate table. 1) Not Null 2)
Unique

Description: - In this we have to perform constraint in SQL Command line. Prerequisites: - In this, we
have some knowledge about SQL and query syntaxes.

Implementation: -

 In this practical we have to do make connection in system using ‘conn system’. In this we have
to first we perform Not Null constraint in employees table in firstname column as shown in Fig-
4.1.
 After that as you can see in Fig-4.2 first is inserted values and in second run insert query. For
define Not Null simply using NULL .
 Second is Unique for that as you can see in the Fig-4.3, I have added Unique first give
constraint in email. As you can see in Fig-4.3. constraint violated.
 Next I remove the constraint in email. After that I’ll take two constraint in one query that is
email and firstname as shown in Fig-4.4. After that inserted one data. In Fig-4.5 as you can see,
if we inserted same first and email then it will be violated Unique constraint.

BTCS402 20BT04035- Jyot Patel


18 | P a g e

Screenshots:

Fig-4.1

Fig-4.2

Fig-4.3

BTCS402 20BT04035- Jyot Patel


19 | P a g e

Fig-4.4

Fig-4.5

BTCS402 20BT04035- Jyot Patel


20 | P a g e

Practical – 5
Aim: - Describe use of following SQL constraint by applying it on appropriate table.

1) Check
2) Primary Key
Description: - In this we have to perform constraint in SQL Command line.
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.

Screenshots
1. Check

BTCS402 20BT04035- Jyot Patel


21 | P a g e

2. Primary key

BTCS402 20BT04035- Jyot Patel


22 | P a g e

Practic-6
Aim:- Demonstrate use of DDL commands with an appropriate example of applying it on a table.
Explain use of following DDL commands.
1) Foregin Key
2) Insert (Syntax to insert of specific number of columns, making script out of insert statement to
insert values)

Description: - In this we have to perform constraint in SQL Command line regarding DDL.

Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.

 To apply key, connect the sql command line.


 Foreign key - is a field in one table, that refers to the PRIMARY KEY in
another table.

Screenshots

BTCS402 20BT04035- Jyot Patel


23 | P a g e

2. Insert(unique)

BTCS402 20BT04035- Jyot Patel


24 | P a g e

Practical-7

Aim:- Describe use of following DDL and DML commands with appropriate example.
1) Update
2) Delete
3) Drop
4) Truncate
5) Merge

Description: - In this we have to perform constraint in SQL Command line regarding DDL & DML.
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.

 To apply key, connect the sql command line.

 UPDATE - used to modify the existing records in a table.

 DELETE - used to delete existing records in a table.

 DROP TABLE - deletes a table in the database.

TRUNCATE TABLE - deletes the data inside a table, but not the table itself.

Screenshots
1.Update
Before update

After update

BTCS402 20BT04035- Jyot Patel


25 | P a g e

2.Delete

3.Turncate

4.Drop Table

BTCS402 20BT04035- Jyot Patel


26 | P a g e

Practical-8

Aim:- Describe use of following TCL commands with appropriate example.


Description: - Explain use of following TCL Command:
1. Commit

2. Savepoint

3. Rollback

Prerequisites: - SQL Database

Screenshots
1.create:

2.Savepoint: 3.Rollback:

BTCS402 20BT04035- Jyot Patel


27 | P a g e

Practical-9

Aim:- Describe use of following DDL and DML commands with appropriate example.
1) Character Function
2) Number Function
3) Date Function

Description: - In this we have to perform constraint in SQL Command line regarding DDL & DML.
Prerequisites: - In this, we have some knowledge about SQL and query syntaxes.

1) Character Function - concat, padding, L R padding

2) Number Function – Round off , Trunc

3) Date Function – timestamp, month and date difference

Screenshots
1. Character

BTCS402 20BT04035- Jyot Patel


28 | P a g e

2. Number

3. Date

BTCS402 20BT04035- Jyot Patel


29 | P a g e

Practical-10 - A

Aim:- Describe various options available with Oracle Date SQL Functions with appropriate example.

Description: - In this we have to perform constraint in SQL Command line regarding SQL.
Prerequisites: -

 TO_CHAR functions is used to typecast a numeric or date input to character type


with format model.

 First, we selection of particular date of joining employees as shown in Fig-10.1 you


can see at what date an employee had joined. DAY parameter is use along with
TO_CHAR () functions.

 Next, we select the data to find out which employee joined at which day using
WHERE clause .

 Next is various formats of date functions. In TO_CHAR () function second parameter


is used for change the format.

 As shown in Fig-10.3 TO_CHAR (SYSDATE, ‘dd mon yy’) : In this function print date,
month in the short-form and year.

 Another is TO_CHAR(SYSDATE, ‘DL’) : it will print day , month, date, year in long
format.

Screenshots :

BTCS402 20BT04035- Jyot Patel


30 | P a g e

BTCS402 20BT04035- Jyot Patel


31 | P a g e

Practical-10 - B

Aim:- Describe use of null values handling oracle SQL Functions , SQL views creating users and DCL

commands with appropriate examples.

Description: - In this we have to create new user and DCL commands with appropriate eg.

Screenshots
10.1

BTCS402 20BT04035- Jyot Patel


32 | P a g e

10.2

10.3

BTCS402 20BT04035- Jyot Patel


33 | P a g e

Here pass for jyot user is “jyot”

BTCS402 20BT04035- Jyot Patel


34 | P a g e

BTCS402 20BT04035- Jyot Patel


35 | P a g e

Practical – 11
Aim:- Demonstrate the use of Oracle and SQL Joins with appropriate examples

Description: - In this we have to perform constraint in SQL Command line regarding Oracle.
Prerequisites: -

1. INNER JOIN:
The INNER JOIN keyword selects record that have matching values in
both tables.

2. LEFT JOIN:
The LEFT JOIN keyword returns all records from the left table, and the
matching records from the right table. The result is 0 records from the right side, if
there is no match.

3. RIGHT JOIN:
The RIGHT JOIN keyword returns all records from the right table
(table2), and the matching records from the left table (table1). The result is 0 records
from the left side, if there is no match.

4. FULL JOIN:
The FULL OUTER JOIN keyword returns all records when there is a match
in left (table1) or right (table2) table records.

5. SELF JOIN:
A self-join is a regular join, but the table is joined with itself.

Screenshots:

BTCS402 20BT04035- Jyot Patel


36 | P a g e

BTCS402 20BT04035- Jyot Patel


37 | P a g e

BTCS402 20BT04035- Jyot Patel


38 | P a g e

Practical – 12
Aim: Create and execute a TRIGGER, PROCEDURE and FUNCTION on a table in SQL.

Screenshots

BTCS402 20BT04035- Jyot Patel


39 | P a g e

BTCS402 20BT04035- Jyot Patel


40 | P a g e

BTCS402 20BT04035- Jyot Patel


41 | P a g e

Practical – 13
Aim : Demonstrate the concept of SUBQUERY in SQL.

Screenshots

BTCS402 20BT04035- Jyot Patel


42 | P a g e

BTCS402 20BT04035- Jyot Patel


43 | P a g e

BTCS402 20BT04035- Jyot Patel

You might also like