Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS Lab File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

S.n. Name of the Program’s PageNo.

Signature
1 Create table with following field. Student
(Roll no., name, age, contact no., course)

2 Insert data in the above table.

3 Select all the student of B.C.A.

Modify the course of student whose name is


4
“Amit”
5 Display all the detail of student.
6 Count total no. of student.

7 Count total no. of student for each course.

8 Find the detail of student whose age is


between20-25.

9 Find the detail of student whose name is start


with A & having at least 5 Character.

Find the detail of student whose name having


10
exist 7 character and last character is “e”.

Consider the following relational shame:


11. Employee (emp no., name, office, age)
Books (Isbn , title, authors, publisher)
Loon (emp no., isbn, date)
I. Write the SQL commands to create
above tables.
II. Write insert Query to insert appropriate
data in the above tables.
III. Write SQL statement to delete a record.
IV. Print the names of employees who have
borrowed any book published by “Mr.
Graw- Hill”.
V. Print the name of employees who have
borrowed all Books Published by “Mr.
Graw- Hill”.
VI. Print the name of employees who have
taken more than 5 Book.
VII. List the name of employees who have
taken all the books whose title is “computer
science”.
VIII. Display the total no. of books for each
publisher.

12. Consider the following relations:


Employee (Employee-name, Street, city)
Works (employee-name, company-name,
salary)
Company (company-name, city)
Manages (Employee-name, manager-
name)
Write SQL queries to create following
tables.

I. Insert at least 5 tables in each table.


II. Modify the Defuel of Employee whose
salary >20000.
III. Display the Defuel of Those Employee
who line in “Noida”.
IV. Display the detail of employee who
works as a Manager.
V. Court total no. of Employee.
VI. Give the detail of employee, who works
in own city.

Experiment No. 01

Object:

Create table with following field.


Student (Roll no., name, age, contact no., course)

Syntax:
CREATE TABLE table_name (
     column1 datatype,
     column2 datatype,
     column3 datatype,
   ....
);

Example:
create table class
(
Roll no int not null,
name varchar(255),
age varchar(255),
contact no varchar(255)
course varchar(255),
);

Result:

Roll no Name Age Contact no. cours


e

Theory:
The CREATE TABLE statement is used to create a new table in a
database. The datatype parameter specifies the type of data the
column can hold (e.g. varchar, integer, date, etc.).
Experiment No. 02

Object: Insert data in the above table.


Syntax:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2,  value3, ...);
Example:
insert into class(rollno,name,age,contactno,course)
values(1,'anil',’19’,'7534263541',’BCA’);
insert into class(rollno,name,age,contactno,course)
values(2,'adam','20','6729428651',’BCA’);
insert into class(rollno,name,age,contactno,course)
values(3,'ravi','18','8077723257',’BBA);
insert into class(rollno,name,age,contactno,course)
values(4,'Gaurav','20','8955496982',’BCA’);
insert into class(rollno,name,age,contactno,course)
values(5,'komal','19','8957268534',’BBA’);

Result:

Roll no Name Age Contact no. cours


e

1 anil 19 7534263541 BCA

2 adam 20 6729428651 BCA

3 Ravi 18 8077723257 BBA

4 Gaurav 20 8955496982 BCA

5 Komal 19 8957268534 BBA

Theory:
The INSERT INTO statement is used to insert new records in a
table.

Experiment No. 03
Object: Select all the student of B.C.A.

Syntax:
SELECT column1, column2, ...
FROM table_name;
Example:

SELECT * FROM table_name;

Conditional select:

SELECT Column FROM table_name Where column = ;

Select Name from Class where course = ‘BCA’;


Result:

Roll no Name Age Contact no. cours


e

1 anil 19 7534263541 BCA

2 adam 20 6729428651 BCA

4 Gaurav 20 8955496982 BCA

Theory:

The SELECT statement is used to select data from a database.

The data returned is stored in a result table, called the result-


set.
Experiment No. 04

Object: Modify the course of student whose name is “Komal”

Syntax:
UPDATE table_name
SET column1 = value1,  column2 = value2, ...
WHERE condition;
Example:

UPDATE Class
SET Course = 'BCA'
WHERE name = ‘komal;
Result:

Roll no Name Age Contact no. cours


e

5 Komal 19 8957268534 BCA

Theory:
The UPDATE statement is used to modify the existing records in
a table.

Note: Be careful when updating records in a table! Notice the


WHERE clause in the UPDATE statement. The WHERE clause
specifies which record(s) that should be updated. If you omit the
WHERE clause, all records in the table will be updated!
Experiment No. 05

Object: Display all the detail of student.

Syntax:
SELECT * FROM table_name;
Example:

SELECT * FROM class;

Result:

Roll no Name Age Contact no. cours


e

1 anil 19 7534263541 BCA

2 adam 20 6729428651 BCA

3 Ravi 18 8077723257 BBA

4 Gaurav 20 8955496982 BCA

5 Komal 19 8957268534 BBA

Theory:

The SELECT statement is used to select all data from a database.

The data returned is stored in a result table, called the result-


set.
Experiment No. 06

Object: Count total no. of student for each course.

Syntax:
SELECT COUNT(column_name)
FROM table_name
WHERE condition;

Example:

SELECT COUNT(name)
FROM class
WHERE course = ‘BCA’

Or

SELECT COUNT(name)
FROM class
WHERE course = ‘BBA’

Result:

Number of record 1
COUNT(course)
3

Or

Number of record 1
COUNT(course)
2

Theory:
The following SQL statement finds the number of student who
studied in BCA or BBA.

Note: NULL values are not counted.


Experiment No. 06

Object: Count total no. of student.

Syntax:
SELECT COUNT(column_name)
FROM table_name

Example:

SELECT COUNT(name)
FROM class

Result:

Number of record 1
COUNT(name)
5

Theory:
The following SQL statement finds the number of student.

Note: NULL values are not counted.

You might also like