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

DATABASE

MANAGEMENT SYSTEM
(DBMS)

LAB REPORT

SUBMITED BY: SUBMITTED TO:

NAME: Anurag Bhattarai Shravan Ghimire

SEMESTER: 4th IT FACULTY

FACULTY: BIM

ROLL NO:

Anurag Bhattarai
INDEX

S.NO. TITLE DATE SIGNATURE

1 Using MYSQL Query 2021/03/18

2 Lab 2 2021/03/18

3 SQL rename operation using 2021/03/18


as clause

4 Operating the display of 2021/03/18


tuple

5 String operation 2021/03/18

6 Using aggregate functions 2021/03/18

7 Using Group by and having 2021/03/18


clause

8 Null and Not Null clause 2021/03/18

9 Update , delete the records 2021/03/18

10 Joins 2021/03/18

11 Working with referential 2021/03/18


integrity constraints

12 Creating user 2021/03/18

Anurag Bhattarai
13 Creating views 2021/03/18

1. Lab I (Using MYSQL Query)

Anurag Bhattarai
a. Login to mysql server using root

Syntax: mysql –u root -p


Description: Login into mysql
Query: mysql –u root -p

b. Create database and tables in mysql

For Database

Syntax: Create database database_name;


Description: It create database.

Query: Create database anurag_bim;

For Table
Syntax: Create table table_name(
Attribute 1,Attribute 2);
Description: It creates table.
Query: Create table student_r12(

Rollno int,

FullName varchar(200),

Faculty varchar(40),

ContactNo varchar(100)

);

Anurag Bhattarai
c. List all database in mysql

Syntax: Show databases;


Description: It display all the databases present.
Query: Show databases;

d. Using particular database

Syntax: Use database_name;


Description: It selects a particular database.
Query: Use prime_bim;

e. Create table (employee, department with necessary foreign key and assume your
own attributes along with data type)

Syntax: Create table table_name(Attribute1,Attributee2); Description: It


creates table with foreign key.

Anurag Bhattarai
Query: CREATE TABLE employee_r12(

id INT PRIMARY KEY, name

varchar(100), address varchar(100),

salary int

);

CREATE TABLE department_r12 (

D_ID int PRIMARY KEY,

Dname varchar(50),

Location varchar(50)

);

CREATE TABLE department_emp_r12 (

D_ID int ,

Emp_id int

);

Alter table department_emp_r12 add constraint dept_emp_pk primary key


(D_ID,Emp_id);
Alter table department_emp_r12 add constraint dept_emp_fk1 foreign key (D_ID)
references department_r12 (D_ID);

Anurag Bhattarai
Alter table department_emp_r12 add constraint dept_emp_fk2 foreign
key(Emp_id) references employee_r12 (id);

f. Listing tables

Syntax: Show tables;


Description: It display tables present in a particular database.
Query: Show tables;

g. Delete the table

Syntax: Drop table table_name; Description: It


deletes a table.

Query: Drop Table College;

Anurag Bhattarai
h. Inserting record in a table (at least 10 entries in each table)

Syntax: Insert into table_name (column1,column2) values(“ ”,” ”),(“ ”,” ”);
Description: Data are inserted into a table. Query: Insert into

student_r12(Rollno,FullName,Faculty,ContactNo)values(1,”Ram”,”bi
m”,9987899997),(2,”Angel”,”bim”,9828906754),….(3,”shyam”,”
bim”,9841000034).

i. Using select query

Syntax: select * from Table_name;


Description: It displays all the data present in particular table.
Query: Select * from student_r12;

Anurag Bhattarai
j. Using where clause

Syntax: select * from table_name where condition;


Description: It displays data whose faculty is Bca.
Query: Select * from student_r12 where Faculty="Bca";

k. Write a query to retrieve all records of employee having salary greater than 50000

Syntax: select * from table_name where condition;


Description: It displays record of those employees whose salary is greater than
50000
Query: Select * from employee_r12 where salary>50000;

l. Write a query to select name, address and salary of all employees who are from
Kathmandu

Syntax: select attribute1, attribute2… from table_name where condition; Description: It


displays record of those employees who are from Kathmandu. Query: select name, address,
salary from employee_r12 where address="Kathmandu";

Page 9
m. Write a query to select name address and salary of all employees whose department
id is 2002.

Syntax: select attribute1,attribute2… from table1,table2 where condition and


table2.attribute(FK)=table1.attribute(PK).

Description: It displays record of those employees whose department id is 2002.


Query: Select a.name, a.address, a.salary from employee_r12 as a,
department_emp_r12 as b where b.D_Id=345 and b.Emp_id =a.Id;

n. Write a query to list all record of the employees who are from Imadol and whose salary
is less than 91000

Syntax: select * from table1 where address=”value” and salary>value.


Description: It displays those record who are from imadol and having salary <91000.

Query: select * from employee_r12 where address="imadol" and salary<91000;

o. Write sql to list name of the employee who are from Kathmandu and whose salary is
greater than 50000
Page 10
Syntax: select * from table1 where address=”value” and salary<value.
Description: It displays those record who are from kathmandu and having salary >50000.

Query: select * from employee_r12 where address="kathmandu" and salary>50000;

p. Write sql to list name of the employee who are form Kathmandu or whose dept id is
2001

Syntax: select name from table1,table2 where address=”value” or D_ID=value and


table2.attribute(FK)=table1.attribute(PK).
Description: It displays records of those employee who are from Kathmandu or whose
dept id is 2001.

Query: Select name,address,b.D_ID from

employee_r12 as a, department_emp_r12 as b where

(a.address=”kathmandu” or D_ID=2001)

and b.Emp_id =a.Id;

q. Write a query to retrieve name, department id and salary of all employees whose
department id is 2002.

Page 11
Syntax: select name, D_ID,salary from table1,table2 where D_ID=value and
table2.attribute(FK)=table1.attribute(PK).

Description: It displays records of that employee whose dept id is 2002

Query: Select name,D_ID,salary from employee_r12 as a,

department_emp_r12 as b where D_ID=2002 and b.Emp_id =a.Id;

r. Write a query to select all records of employees where salary is between 2000 to
18000.

Syntax: select name,D_ID,salary from table1,table2 where salary between 2000 and
18000 and table2.attribute(FK)=table1.attribute(PK).

Description: It displays records of those employee whose salary is between 2000


& 18000
Query: Select * from employee_r12

where salary between 2000 and 18000;

s. Write a query to select all records of employees where salary is not between 2000 to
18000.

Syntax: select name,D_ID,salary from table1,table2 where salary not between 2000 and
18000 and table2.attribute(FK)=table1.attribute(PK).

Description: It displays records of those employee whose salary is not between


2000 & 18000
Page 12
Query: Select * from employee_r12 where salary not between 2000 and 18000;

t. Write a query to retrieve records of employee whose department id is one of the

flowing (2006, 2004, 2034,5001)

Syntax: select * from table1,table2 where D_ID in(value1,value2…) and


table2.attribute(FK)=table1.attribute(PK).

Description: It displays records of those employee whose dept id is (2006,2004,2034,5001).

Query: Select a.*, b.dname, b.d_id from employee_r12 as a,

department_r12 as b, department_emp_r12 as c where c.D_ID

in(2006,2004,2034,5001) and c.Emp_id =a.Id and b.d_id =c.d_Id;

u. Write a query to retrieve records of employee whose department id is not one of the
flowing (2006, 2004, 2034, 5001).

Syntax: select * from table1,table2 where condition and


table2.attribute(FK)=table1.attribute(PK).

Description: It displays records of those employee whose dept id is not


(2006,2004,2034,5001).

Page 13
Query: Select a.*, b.dname, b.d_id from employee_r12 as a,

department_r12 as b, department_emp_r12 as c where c.D_ID not

in(2006,2004,2034,5001) and c.Emp_id =a.Id and b.d_id =c.d_Id;

v. Write a query to list all distinct names of employee table.

Syntax: select distinct attribute from table1;


Description: It displays distinct name of employee.
Query: select distinct name from employee_r12;

w. Write a query to list all distinct addresses from employee table.

Syntax: select distinct attribute from table1;


Description: It displays distinct address of the employee. Query:
select distinct name,address from employee_r12;

Page 14
2. Lab 2:

a. Write a query to delete employee record which has employee id 106.

Syntax: delete from table where condition;.


Description: It delete the record of those employee whose id is 106
Query: delete from employee_r12 where id=106;

b. Write a query to change the address of employee whose employee id is 111.

Syntax: update table set address=”value” where id=111;


Description: It update the address of employee whose id is 111
Query: update employee_r12 set address="kathmandu" where id=111;

c. Write a query which will increase the salary of each department by Rs 1000

Page 15
Syntax: update table set salary=salary+value.
Description: It increase the salary of the employee bt rs1000 Query:
update employee_r12 set salary=salary+1000;

d. Write a query to increase salary of employees by 5% whose salary is more than 9000.

Syntax: update table set salary=salary+value+salary where salary>value.


Description: It display salary of employee by increasing 5% of the salary.
Query: update employee_r12 set salary=salary+0.05+salary where
salary>9000;

Page 16
e. Write a query to change the department id of employees whose old department id is 2001.
The new department id should be 5001.

Syntax: update table set D_ID=value where D_ID=value.


Description: It change the department id to 5001 whose department id is 2001 Query:
update department_r12 set D_ID=5001 where D_ID=2001;

f. Write a query to delete all employee record who are from Bhaktapur.

Syntax: delete from table where address=”value”.


Description: It deletes the record of those employee who are from bhaktapur.
Query: delete from employee_r12 where address="bhaktapur";

3. SQL rename operation using AS clause.

Page 17
a. Write a query to display the records of department table with following table heads:
Department_ko_id, Department_ko_Naam. Department_ko_Location.

Syntax: select column1 as name1,column2 as name2…column n as name n from


table;

Description: It displays the records of department table.


Query: select D_ID as Department_Ko_id,Dname as
Department_Ko_Naam,Empid as Employee_ko_naam from department_r12;

b. Write a query to list employee id, employee name, department locations from employee
and department tables.

Syntax: select table1.column,table2.column from table1 as e,table2 as d where


table1.attribute(PK)=table2.attribute(FK).

Description: It displays record of employees from employee and department table.

Query: select e.id,e.name,d.Dname


FROM Employee_r12 AS e,department_r12 AS d WHERE
e.id=d.Empid;

Page 18
c. Write a query that display employee name and their yearly salary.

Syntax: select column1,column2 as name1 from employee_r12.


Description: It display the yearly salary of the employee.
Query: select name,salary*12 as yearlysalary from employee_r12;

4. Ordering the display of tuple.

a. Write a SQL query to list all employee name, their address and salary in:

i. ascending order of salary

Syntax: select * from table order by column asc.


Page 19
Description: It display list of employee salary in ascending order. Query:
select * from employee_r12 order by salary asc;

ii. descending order of salary

Syntax: select * from table order by column desc.


Description: It display salary of employee in descending order.
Query: select * from employee_r12 order by salary desc;

iii. ascending order of their name

Syntax: select * from table order by column asc.


Description: It displays record of employee in ascending order of their name.
Query: select * from employee_r12 order by name asc;

Page 20
iv. descending order of their name

Syntax: select * from table order by column desc.


Description: It displays record of employee in descending order of their name.
Query: select * from employee_r12 order by name desc;

v. ascending order of employee name and descending order of salary

Syntax: select column1,column2 from table_name order by value,value.


Description: It displays records of employee in ascending order of their name
and descending order of their salary.

Query: select name, salary from employee_r12 order by salary desc, name ;

Page 21
5. String Operation

a. Write a SQL query to list names of employee from employee table where

i. name start with “Mi”

Syntax: select * from table where name like”value”.


Description: It displays records of employee whose name starts with MI.
Query: select * from employee_r12 where name like"mi%";

ii. name ends with “a”

Syntax: select * from table where name like”value”.


Description: It displays records of employee whose name ends with a. Query: select
* from employee_r12 where name like"%a";

Page 22
iii. name starts with “M” and ends with “n”

Syntax: select * from table where name like”value%value”.


Description: It displays records of employee whose name starts with m and ends
with a.

Query: select * from employee_r12 where name like"m%a";

b. Write a sql query to

i. Display department id and their location where department includes the substring
“par”

Syntax: select * from table where name like”value”.


Description: It displays records of employee whose department include substring
par..

Query: select * from department_r12 where Dname like”%par%”;

Page 23
c. Write a sql query to list id and names of employee from employee table where
the name starts with “M” and end with “n” and has exactly 5 characters

Syntax: select column1,column2 from table where name like"value";

Description: It displays records of employee whose name start with m and ends with
n and have exactly 5 character.

Query: select id,name from employee_r12 where name like"m%___%a";

d. Write a sql query to display employee name and address where name include a
substring “il” and address starts with “I”

Syntax : select column1, column2 from table where column1 like”value” and column2
like”value”.

Description: It displays records of employee whose name includes il and address


start with i

Query: select name,address from employee_r12 where name like"%il%" and address
like"l%";

6. Using aggregate functions

Page 24
a. Write a query to find

i. Maximum salary of employee

Syntax: select column1,max(column) from tbl.


Description: It displays record of those employee whose salary is high.
Query: select max(salary) from employee_r12;

ii. Minimum salary of employee

Syntax: select column1,min(column) from tbl.


Description: It displays record of those employee whose salary is low.
Query: select min(salary) from employee_r12;

iii. Average salary of employee

Syntax: select avg(column) from tbl.


Description: It displays average salary of the employee.
Query: select avg(salary) from employee_r12.
Page 25
iv. Find total number of record in department table

Syntax: select count(*) from tbl.


Description: It displays the total record in department table.
Query: select * from department_r12;

v. Number of employees from Kathmandu

Syntax: select count(column) from tbl where address=”kathmandu”;


Description: It counts the no of employee who are from Kathmandu.

Query: select count(address) from employee_r12 where address="kathmandu";

vi. Find total salary of employee table

Syntax: select sum(column) from tbl.

Page 26
Description: It displays sum of salary.
Query: select sum(salary) from employee_r12.

7. Using Group by and having clause

a. Write a query to find

i. Average salary of employee of each department

Syntax: select table1.columnn1,table1.column2,avg(table3.column1) from table1 as


a ,table 2 as b,table3 as c where condition1 and condition2 group by
column1,column2

Description: It displays the record of employee from each department having average
salary

Query: select a.d_id,a.dname,avg(c.salary) from department_r12 as


a,department_emp_r12 as b,employee_r12 as c where a.D_ID=b.D_ID and b.emp_id=c.id
group by a.d_id,a.dname;

Page 27
ii. Minimum salary of employee of each employee address

Syntax: select column1,min(column2) from table group by column1.


Description: It displays the record of employee from each department with minimum
salary according to their address.

Query: select address,min(salary) from employee_r12 group by address;

iii. Minimum salary of employee of each employee having average salary greater than
3000

Syntax: select column1,column2 from table 1 as a(selecr column1,avg(column2) avg


from table1 group by column) b where condition.

Page 28
Description: It displays the record of each employee having average salary greater
than 3000.

Query: select name, salary from employee_r12 as a, (select address, avg(salary) avg_sal
from employee_r12 group by address) as b where b.address=a.address and
b.avg_sal>3000;

OR
select name,min(salary) from employee_r12 group by name having avg(salary)>3000;

iv. Number of employees in each department

Syntax: select table.column1,count(table2.column1)as name from table 1,table2


where condition.

Page 29
Description: It displays the record of employee from each department .
Query: select a.Dname, count(b.emp_id) as "no of employees" from
department_r12 as a ,department_emp_r12 as b where a.d_id=b.d_id group by
a.d_id;

v. Total salary from each address except from “Kathmandu”

Syntax: select column1,sum(column2) from table where condition group by column.

Description: It displays the record of employee’s total salary except from employee
of Kathmandu.

Query: select address,sum(salary) from employee_r12 where address


<>’Kathmandu’ group by address;

vi. Average salary of employee of each department who are from “lalitpur”,

“kathmandu” and “Imadol”

Page 30
Syntax: select
table1.column1,table1.column2,table2.column1,avg(table2.column2) from table
where condition.

Description: It displays the record of employee of each department who are from
lalitpur, Kathmandu and imadol.

Query: select a.d_id,a.dname,c.address, avg(c.salary) from department_r12 as


a,department_emp_r12 as b,employee_r12 as c where a.D_ID=b.D_ID and

b.emp_id=c.id and c.address in(”Kathmandu”,”lalitpur”,”imadol”) group by


a.d_id,a.dname, c.address;

vii. Number of employee from each address where salary is greater than 8000

Syntax: select table1.column1,count(column1) from table where condition.


Description: It displays the record of employee from each department whose salary
is greater than 8000.

Query: select address,count(address) from employee_r12 where salary>8000


group by address;

Page 31
8. NULL and NOT NULL clause
a. Write a query to:

i. List all records of employee whose address is empty

Syntax: select * from table where condition.


Description: It displays the record of those employee whose address is empty.
Query: select * from employee_r12 where address is null;

ii. Display name of employee whose address is not empty

Syntax: select column from table 1 where condition.


Description: It displays the record of those employee whose address is not empty.

Query: select name from employee_r12 where address is not null ;

Page 32
iii. Display name and address and salary of employee whose address is not null and salary
is greater than 8000

Syntax: select column1,column2 from table where conditions.


Description: It displays the record of employee whose address is not null and salary
is greater than 8000.
Query: select name,address from employee_r12 where address is not null and
salary>8000;

9. Update delete the records

a. Write a query to update the name of employee whose id =1 to Ram id = 2 to


John and id = 9 to Hari

Syntax: update table set column1=value where column2=value.


Description: It update name of employee whose id is 1,2,and 9 to ram, john and
hari.
Page 33
Query: update employee_r12 set name="ram" where id=123;
update employee_r12 set name="john" where id=234;
update employee_r12 set name="hari" where id=911;

b. Delete the employee whose salary is less than 10000(if not present in
database first insert 5 employees with salary less than 10000 show the table
and delete the table)

Syntax: delete from table where condition.


Description: It deletes the record of employee whose salary is less than 10000. Query:
delete from employee_r12 where salary<10000;

Page 34
10. Joins

a. Create table

i. Address (add_id, address,state, city,zip, country)

Syntax: Create table table_name(Attribute1,Attributee2);


Description: It creates table with name address.

Query: create table address(add_id int not null auto_increment primary


key,address varchar(50),state varchar(50),city varchar(100),zip varchar(40),country
varchar(100));

ii. Students (stud_id, name,email,phone,dept_id,add_id)

Syntax: Create table table_name(Attribute1,Attributee2);


Description: It creates table with name students.

Query: create table students(std_id int not null primary key,name varchar(100),email
varchar(100),phone varchar(20),dep_id int,add_id int,foreign key(add_id)references
address(add_id));
Page 35
iii. Department(dept_id,dept_name) Assusme necessary data type

Syntax: Create table table_name(Attribute1,Attributee2);


Description: It creates table with name department.

Query: create table department(SNO int, dept_id int not null,dept_name varchar(20)not
null,

primary key(dept_id,dept_name),foreign key(SNO)references students(std_id));

b. Demonstrate the full join concept with sql query and table for the address,
students and department table

Syntax: select table1.*,table2.*,table3.* from table1 join table2 on


table1.attribte(pk)=table2.attribute(fk) join on table3 on
table3.attribute(pk)=table2.attribute(fk)

Description: It displays record of students with their name, address and department
with full join concept.

Query: select students.*, address.*,department.* FROM address JOIN students ON


students.add_id = address.add_id Join department ON department.SNO =
students.add_id;

Page 36
c. Demonstrate the Inner join concept with sql query and table for the address,
students and department table

Syntax: select table1.*,table2.*,table3.* from table1 inner join table2 on


table1.attribte(pk)=table2.attribute(fk) inner join on table3 on
table3.attribute(pk)=table2.attribute(fk)

Description: It displays record of students with their name, address and department
with inner join concept.

Query: Select students.name, address.*, department.* FROM address Inner JOIN


students ON students.add_id = address.add_id Inner Join department ON
department.SNO = students.add_id;

d. Demonstrate the left join concept with sql query and table for the address,
students and department table

Syntax: select table1.*,table2.*,table3.* from table1 left join table2 on


table1.attribte(pk)=table2.attribute(fk) left join on table3 on
table3.attribute(pk)=table2.attribute(fk)

Description: It displays record of students with their name, address and


department with left join concept.

Page 37
Query: Select students.name, address.address,address.state,address.country,
department.* FROM address left JOIN students ON students.add_id =
address.add_id left JOin department ON department.SNO = students.add_id;

e. Demonstrate the right join concept with sql query and table for the address,
students and department table

Syntax: select table1.*,table2.*,table3.* from table1 right join table2 on


table1.attribte(pk)=table2.attribute(fk) right join on table3 on
table3.attribute(pk)=table2.attribute(fk)

Description: It displays record of students with their name, address and department
with right join concept.

Query: Select students.name, address.address,address.state,address.country,


department.* FROM address right JOIN students ON students.add_id = address.add_id
right JOin department ON department.SNO = students.add_id;

Page 38
11. Working with referential integrity constraints

a. Creating a table with foreign key(assume your table with necessary table except
already created table)

Syntax: Create table table_name(Attribute1,Attributee2);


Description: It creates table named country and citizen .

Query: create table country_r12(id int not null auto_increment primary key, name
varchar(20));

create table citizen_r12(id int not null auto_increment primary key, name
varchar(20),email varchar(50),c_id int, foreign key(c_id) references country_r12(id));

b. Insert values in the tables created in 11.a


Syntax: Insert into table(column)values(),()… Description: It inserts
data into tables. Query: insert into country_r12(name) values(“Nepal”),
(“USA”),(“UK”),(“japan”),(“Maldives”),(“Africa”),(“Brazil”),

(“Canada”);

Page 39
insert into citizen_r12(name, email, c_id) values
( "K","K@gmail.com",1),("A","A@gmail.com",2),("B","B@gmail.com",3),("C","
C@gmail.com",5),("D","D@gmail.com",4),("E","E@gmail.com",6),("F","F@gma
il.com",7),("G","G@gmail.com",8),("H","H@gmail.com",2),("I","I@gmail.com",5

);

c. Inserting values to foreign key that are not in primary key

Syntax: insert into table(column1,column2)values(),()...


Description: It insert data into table.
Query: insert into citizen_r12(name,email,c_id) value
(“Ramprasad”,”Ramprasad@gmail.com”,9);

d. Insert null to foreign key

Page 40
Syntax: insert into table(column1,column2,column3)values(),(),..
Description: It inser data into tables.
Query: insert into citizen_r12(name,email,c_id) values
(“Ramprasa”,”Ramprasad@gmail.com”,null);

e. Delete record which is referenced in another table

Syntax: delete from table where condition.


Description: It deletes record inside a table.
Query: delete from country_r12 where id=1;

f. Deleting record from child table

Syntax: delete from table where condition.


Description: It deletes record inside a table.
Query: delete from citizen_r12 where id=10;

Page 41
g. Update primary key value which is referenced in child table

Syntax: update table set column=value where condition.


Description: It updates data inside a table.
Query: update country_r12 set id=10 where id=7;

h. Update foreign key in child table

Syntax: update table set column=value where condition.


Description: It updates data inside a table.
Query: update citizen_r12 set c_id=1 where id=8;

12. Create users

a. Write a query to create users in MYSQL

Syntax: create user “Username”@”localhost” identified by”password”.


Description: It creates new user in mysql
Query: Create user “raunak”@”localhost” identified by”raunak123”;

b. Login through different users

Page 42
Syntax: mysql –u raunak –p
Description:It login into different users created in mysql.
Query : mysql -u raunak –p

c. Grant privileges to users and try to do privileged actions

Syntax: grant all privileges on database.* to “user”@”localhost”. Description:


It give permission to newly created user to access different databases and
tables.

Query: GRANT ALL PRIVILEGES ON labreport.* TO 'raunak'@'localhost';

Page 43
d. Revoke privileges

Syntax: revoke all privileges,grant option from “user”@”localhost”.


Description: It declines all the permission given to created user.
Query: REVOKE ALL PRIVILEGES, GRANT OPTION FROM
'raunak'@'localhost';

Page 44
13. Creating Views from table created in 10.a

a. View_2002 from dep_id from student table

Syntax: create view view_name as select * from table where condition.


Description: It creates view name view_2002.
Query: Create view view_2002 as select
* from students where dep_id=2002;

b. View_science with columns stud_id,dept_id,student_name,dept_name using


student and department table

Syntax: create view view_name as select table1.column,table2.column from table1,table2


where table1.attribute(pk)=table2.attribute(fk).

Description: It creates view name view_science.


Query: Create view view_science as select

Page 45
students.std_id,students.n
ame,department.dept_id,department.dept_name from
students,department where students.std_id=department.SNO;

c. Write a query to demonstrate update operation using view

Syntax: update view_name set column=value where condition.


Description: It update table using view.
Query: UPDATE view_science Set name="RAMA" WHERE std_id = 6;

d. Insert record using view


Page 46
Syntax: insert into view_name (column1,column2,column3..)values(),(),(),..
Description: It insert data into table through view.”,2002,6);
Query: insert into view_2002
( std_id,name,email,phone,dep_id,add_id)values(13,”Ramlal”,”ramal@gmail.co
m”,”23456789000

e. Delete records through view

Syntax: delete from view_name where condition.


Description: It deletes record of table using view. Query:
delete from view_2002 where std_id=13;

Page 47
f. Delete view

Syntax: drop view_name.


Description: It deletes view created.
Query: drop view view_2002;

Page 48

You might also like