0% found this document useful (0 votes)
41 views5 pages

Ex. No. 4 Views, Locks and Partitions: To Create A Table Emp01

1. The document describes creating views, locks, and partitions from tables in SQL. It creates two tables, emp01 and student01, and inserts data into them. 2. It then creates two views - v01 displays records from student01 where total is greater than 400, and view01 displays records from emp01 where salary is 12000. 3. The views are queried to display the records that meet the view criteria.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Ex. No. 4 Views, Locks and Partitions: To Create A Table Emp01

1. The document describes creating views, locks, and partitions from tables in SQL. It creates two tables, emp01 and student01, and inserts data into them. 2. It then creates two views - v01 displays records from student01 where total is greater than 400, and view01 displays records from emp01 where salary is 12000. 3. The views are queried to display the records that meet the view criteria.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ABDULLAH.

H 10MCA01

Ex. No. 4
VIEWS, LOCKS AND PARTITIONS

AIM:
To create views, locks and partitions from the table.

1. VIEWS:

To create a table emp01:

SQL> create table emp01(EID number(6),ENAME varchar(12), DEPARTMENT


varchar(12),DESIGNATION varchar(12),SALARY number(7));

Table created.

To insert tuples into the table employee01:

SQL> insert into emp01


values(&eid,'&ename','&department','&designation',&salary);
Enter value for eid : 1001
Enter value for ename : Anish
Enter value for department : Sales
Enter value for designation : M.Com
Enter value for salary : 12000
old 1: insert into emp01
values(&eid,'&ename','&department','&designation',&salary)
new 1: insert into emp01 values(1001,'Ashwini','Sales','M.Com',12000)

1 row created.

SQL> insert into emp01


values(&eid,'&ename','&department','&designation',&salary);
Enter value for eid : 1002
Enter value for ename : Karthi
Enter value for department : Accounts
Enter value for designation : M.Com
Enter value for salary : 01000
old 1: insert into emp01
values(&eid,'&ename','&department','&designation',&salary)
new 1: insert into emp01 values(1002,'Dharun','Accounts','M.Com',01000)

1 row created.
ABDULLAH. H 10MCA01

SQL> insert into emp01


values(&eid,'&ename','&department','&designation',&salary);
Enter value for eid : 1003
Enter value for ename : Yasin
Enter value for department : Accounts
Enter value for designation : B.Com
Enter value for salary : 10000
old 1: insert into emp01
values(&eid,'&ename','&department','&designation',&salary)
new 1: insert into emp01 values(1003,'Yasin','Accounts','B.Com',10000)

1 row created.

SQL> insert into emp01


values(&eid,'&ename','&department','&designation',&salary);
Enter value for eid : 1004
Enter value for ename : Akila
Enter value for department : Production
Enter value for designation : B.Com(CA)
Enter value for salary : 12000
old 1: insert into emp01
values(&eid,'&ename','&department','&designation',&salary)
new 1: insert into emp01 values(1004,'Ashok','Production','B.Com(CA)',14000)

1 row created.

SQL> insert into emp01


values(&eid,'&ename','&department','&designation',&salary);
Enter value for eid : 1005
Enter value for ename : Kalpana
Enter value for department : Sales
Enter value for designation : MBA
Enter value for salary : 18000
old 1: insert into emp01
values(&eid,'&ename','&department','&designation',&salary)
new 1: insert into emp01 values(1005,'Kalpana','Sales','MBA',18000)

1 row created.

To view the tuples in the table emp01:


SQL> select * from emp01;
ABDULLAH. H 10MCA01

EID ENAME DEPARTMENT DESIGNATION SALARY


---------- ------------ ------------ ------------ ----------
1001 Anish Sales M.Com 12000
1002 Karthi Accounts M.Com 11000
1003 Yasin Accounts B.Com 10000
1004 Akila Production B.Com(CA) 12000
1005 Kalpana Sales MBA 18000

To create a table student01:


SQL> create table student01(ROLLNO number(6),NAME varchar(12),TOTAL
number

Table created.

To insert tuples into the table student01:


SQL> insert into student01 values(&rollno,'&name',&total,'&grade');
Enter value for rollno : 100
Enter value for name : Arjun
Enter value for total : 450
Enter value for grade :A
old 1: insert into student01 values(&rollno,'&name',&total,'&grade')
new 1: insert into student01 values(100,'Arjun',450,'A')

1 row created.

SQL> /
Enter value for rollno : 103
Enter value for name : Arun
Enter value for total : 460
Enter value for grade :A
old 1: insert into student01 values(&rollno,'&name',&total,'&grade')
new 1: insert into student01 values(103,'Arun',460,'A')

1 row created.

SQL> /
Enter value for rollno : 104
Enter value for name : Jana
Enter value for total : 420
Enter value for grade :B
old 1: insert into student01 values(&rollno,'&name',&total,'&grade')
new 1: insert into student01 values(104,'Jana',420,'B')

1 row created.
ABDULLAH. H 10MCA01

Enter value for rollno : 106


Enter value for name : Surya
Enter value for total : 380
Enter value for grade :C
old 1: insert into student01 values(&rollno,'&name',&total,'&grade')
new 1: insert into student01 values(106,'Surya',380,'C')

1 row created.

SQL> /
Enter value for rollno : 101
Enter value for name : Vishnu
Enter value for total : 400
Enter value for grade :B
old 1: insert into student01 values(&rollno,'&name',&total,'&grade')
new 1: insert into student01 values(101,'Vishnu',400,'B')

1 row created.

To view tuples in the table student01 :


SQL> select * from student01;

ROLLNO NAME TOTAL GRADE


---------- ------------ ---------- ------
100 Arjun 350 A
103 Arun 460 A
104 Jana 420 B
106 Surya 380 C
101 Vishnu 400 B

To create the view named v01 to display the records whose total greater than 400 in
the table student01 :
SQL>Create view v01 as(select * from student01 where total>400);

View created.

To view the tuples from view named v01:


SQL>select * from v01;

ROLLNO NAME TOTAL GRADE


---------- ------------ ---------- ------
103 Arun 460 A
104 Jana 420 B
101 Vishnu 400 B
ABDULLAH. H 10MCA01

To create the view named view01 to display the records whose salary is 12000:
SQL>Create view view01 as(select * from emp01 where salary=12000);

View created.

To view the tuples from view named v01:


SQL>select * from view01;

EID ENAME DEPARTMENT DESIGNATION SALARY


---------- ------------ ------------ ------------ ----------
1001 Anish Sales M.Com 12000
1004 Akila Production B.Com(CA) 12000

You might also like