DBMS Lab
DBMS Lab
Week-1: CREATION OF
TABLES
1. Create a table called
Employee with the
followingstructure.
Name Type
Empno Number
Ename Varchar2(20)
Job Varchar2(20)
Mgr Number
Sal Number
a. Add a column
commission with domain
to the Employeetable.
b. Insert any five records
into the table.
c. Update the column
details of job
d. Rename the column of
Employ table using alter
command.
e. Delete the employee
whose empno is19.
List of Experiments:
Name Type
Empno Number
Ename Varchar2(20)
Job Varchar2(20)
Mgr Number
Sal Number
SOLUTION:
SQL> create table
employee (empno
number,ename
varchar2(10), job
varchar2(10),mgr
number,sal number);
Table created.
SQL> desc employee;
Name
Null?
Type
EMPNO
NUMBER
ENAME
VARCHAR2(10)
JOB
VARCHAR2(10)
MGR
NUMBER
SAL
NUMBER
SQL> create table employee (empno number,ename varchar2(10), job varchar2(10),mgr
number,sal number);
Table created.
SQL> desc employee;
a. Add a column
commission with domain
to the Employee table.
SQL> alter table employee
add(commission number);
Table altered.
SQL> desc employee;
a. Add a column commission with domain to the Employee table.
Table altered.
WEEK -2
QUERIES USING DDL
AND DML
1.
a. Create a user and grant
all permissions to the user.
b. Insert the any three
records in the employee
table and use rollback.
Check theresult.
c. Add primary key
constraint and not null
constraint to the employee
table.
d. Insert null values to the
employee table and verify
the result.
WEEK -2
QUERIES USING DDL AND DML
1.
SOLUTION:
a)
create a user and grant
all permissions to the
user.
CONNECT <USER-
NAME>/<PASSWORD>@<
DATABASE NAME>;
--Create user query
CREATE USER <USER
NAME> IDENTIFIED BY
<PASSWORD>;
--Provide roles
GRANT
CONNECT,RESOURCE,DBA
TO <USER NAME>;
--Assigning privileges
GRANT CREATE SESSION
GRANT ANY PRIVILEGE TO
<USER NAME>; GRANT
UNLIMITED
TABLESPACE TO <USER
NAME>;
--Provide access to tables.
SOLUTION:
a)
--Provide roles
--Assigning privileges
GRANT CREATE SESSION GRANT ANY PRIVILEGE TO <USER NAME>; GRANT UNLIMITED
TABLESPACE TO <USER NAME>;
b)
Insert the any three records in the employee table and use rollback. Check the result
SQL> rollback;
Rollback complete
c)
Add primary key constraint and not null constraint to the employee table.
SQL> alter table employee modify(empno number primary key, ename varchar2(10) not null); Table
altered.
SQL> desc employee;
d)