0% found this document useful (0 votes)
6 views16 pages

DBMS Exp 3

Dbms

Uploaded by

nazarethn321
Copyright
© © All Rights Reserved
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)
6 views16 pages

DBMS Exp 3

Dbms

Uploaded by

nazarethn321
Copyright
© © All Rights Reserved
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/ 16

SQL*Plus: Release 11.2.0.2.

0 Production on Tue Feb 27 11:25:01 2024

Copyright (c) 1982, 2014, Oracle. All rights reserved.

SQL> connect

Enter user-name: system

Enter password:

Connected.

SQL> create table t1(rollno int,age int);

Table created.

SQL> insert into t1 values(05,19)

2 ;

1 row created.

SQL> insert into t1 values(03,20);

1 row created.

SQL> insert into t1 values(01,18);

1 row created.
SQL> select * from t1;

ROLLNO AGE

---------- ----------

5 19

3 20

1 18

SQL> create user nash identified by jojo;

User created.

SQL> connect

Enter user-name: nash

Enter password:

ERROR:

ORA-01045: user NASH lacks CREATE SESSION privilege; logon denied

Warning: You are no longer connected to ORACLE.

SQL> connect

Enter user-name: system

Enter password:

Connected.

SQL> grant create session to nash;


Grant succeeded.

SQL> connect

Enter user-name: nash

Enter password:

Connected.

SQL> select * from system.t1

2 ;

select * from system.t1

ERROR at line 1:

ORA-00942: table or view does not exist

SQL> connect

Enter user-name: system

Enter password:

Connected.

SQL> select * from system.t1;

ROLLNO AGE

---------- ----------

5 19

3 20
1 18

SQL> grant select,insert on t1 to system;

Grant succeeded.

SQL> grant select,insert on t1 to nash;

Grant succeeded.

SQL> connect

Enter user-name: nash

Enter password:

Connected.

SQL> select * from t1;

select * from t1

ERROR at line 1:

ORA-00942: table or view does not exist

SQL> select * from system.t1;

ROLLNO AGE

---------- ----------
5 19

3 20

1 18

SQL> insert into system.t1 values(06,18);

1 row created.

SQL> select * from system.t1;

ROLLNO AGE

---------- ----------

5 19

3 20

1 18

6 18

SQL> connect

Enter user-name: system

Enter password:

Connected.

SQL> revoke insert on t1 from nash;

Revoke succeeded.
SQL> connect

Enter user-name: nash

Enter password:

Connected.

SQL> insert into system.t1 values(06,18);

insert into system.t1 values(06,18)

ERROR at line 1:

ORA-01031: insufficient privileges

SQL> connect

Enter user-name: system

Enter password:

Connected.

SQL> create table t2(rollno int,age int);

Table created.

SQL> insert into t2 values(01,18)

2 ;

1 row created.

SQL> insert into t2 values(03,20);


1 row created.

SQL> insert into t2 values(05,19);

1 row created.

SQL> insert into t2 values(06,17);

1 row created.

SQL> select * from t2;

ROLLNO AGE

---------- ----------

1 18

3 20

5 19

6 17

SQL> commit;

Commit complete.

SQL> delete from t2 where rollno=1;


1 row deleted.

SQL> select * from t2;

ROLLNO AGE

---------- ----------

3 20

5 19

6 17

SQL> rollback;

Rollback complete.

SQL> select * from t2;

ROLLNO AGE

---------- ----------

1 18

3 20

5 19

6 17

SQL> delete from t2 where rollno=1;


1 row deleted.

SQL> savepoint e1;

Savepoint created.

SQL> delete from t2 where rollno=6;

1 row deleted.

SQL> select * from t2;

ROLLNO AGE

---------- ----------

3 20

5 19

SQL> savepoint e2;

Savepoint created.

SQL> delete from t2 where rollno=3;

1 row deleted.
SQL> select * from t2;

ROLLNO AGE

---------- ----------

5 19

SQL> rollback to e2;

Rollback complete.

SQL> select * from t2;

ROLLNO AGE

---------- ----------

3 20

5 19

SQL>

Post experiment:

SQL> connect seb05


Enter password:
Connected.
SQL> create table Employee (
2 EID int NOT NULL UNIQUE,
3 ename varchar2(20),
4 ecountry varchar2(20) DEFAULT 'India',
5 econtact int,
6 esalary int CHECK (esalary>=30000)
7 );

Table created.

SQL> desc employee


Name Null? Type
----------------------------------------- -------- ----------------------------
EID NOT NULL NUMBER(38)
ENAME VARCHAR2(20)
ECOUNTRY VARCHAR2(20)
ECONTACT NUMBER(38)
ESALARY NUMBER(38)

SQL>

SQL> connect

Enter user-name: SEB05

Enter password:

Connected.

SQL> desc employee

Name Null? Type

----------------------------------------- -------- ----------------------------

EID NOT NULL NUMBER(38)

ENAME VARCHAR2(20)

ECOUNTRY VARCHAR2(20)

ECONTACT NUMBER(38)

ESALARY NUMBER(38)

SQL> create user nash3 identified by jojo;

User created.
SQL> grant insert on employee to nash\3;

grant insert on employee to nash\3

ERROR at line 1:

ORA-00911: invalid character

SQL> grant insert on employee to nash3;

Grant succeeded.

SQL> connect

Enter user-name: nash3

Enter password:

ERROR:

ORA-01045: user NASH3 lacks CREATE SESSION privilege; logon denied

Warning: You are no longer connected to ORACLE.

SQL> connect

Enter user-name: SEB05

Enter password:

Connected.

SQL> grant create session to nash3;


Grant succeeded.

SQL> connect

Enter user-name: nash3

Enter password:

Connected.

SQL> insert into SEB05.employee values(0001,'nash','India',9875418320,36000);

1 row created.

SQL> insert into SEB05.employee values(0002,'rimaru','Japan',9875987208,40000);

1 row created.

SQL> connect

Enter user-name: SEB05

Enter password:

Connected.

SQL> revoke insert on employee to nash3;

revoke insert on employee to nash3

ERROR at line 1:

ORA-00905: missing keyword


SQL> revoke insert on employee from nash3;

Revoke succeeded.

SQL> connect

Enter user-name: nash3

Enter password:

Connected.

SQL> insert into SEB05.employee values(0003,'teju','Japan',987457208,47000);

insert into SEB05.employee values(0003,'teju','Japan',987457208,47000)

ERROR at line 1:

ORA-00942: table or view does not exist

SQL> connect

Enter user-name: SEB05

Enter password:

Connected.

SQL> select * from employee

2 ;

EID ENAME ECOUNTRY ECONTACT ESALARY

---------- -------------------- -------------------- ---------- ----------


1 nash India 9875418320 36000

2 rimaru Japan 9875987208 40000

SQL> commit;

Commit complete.

SQL> insert into employee values(0003,'teju','Japan',987457208,47000);

1 row created.

SQL> savepoint a;

Savepoint created.

SQL> insert into employee values(0004,'anna','russian',934457208,50000);

1 row created.

SQL> savepoint b;

Savepoint created.

SQL> rollback to b;
Rollback complete.

SQL> select * from employee;

EID ENAME ECOUNTRY ECONTACT ESALARY

---------- -------------------- -------------------- ---------- ----------

1 nash India 9875418320 36000

2 rimaru Japan 9875987208 40000

3 teju Japan 987457208 47000

4 anna russian 934457208 50000

SQL> rollback;

Rollback complete.

SQL> select * from employee;

EID ENAME ECOUNTRY ECONTACT ESALARY

---------- -------------------- -------------------- ---------- ----------

1 nash India 9875418320 36000

2 rimaru Japan 9875987208 40000

SQL>

You might also like