13.connect A New DBA To The Database and Create Other Users That Access The Database Based On Your Use Case

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

12

Enter user-name: sys as sysdba

Enter password:

Connected to:

Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> alter pluggable database bms open;

Pluggable database altered.

SQL> alter session set container=bms;

Session altered.

SQL> connect neva/neva@//localhost:1521/bms;

Connected.

SQL> show user;

USER is "NEVA"

13.Connect a new DBA to the database and create other users that access the
database based on your use case.

SQL> connect neva/neva@//localhost:1521/bms;

Connected.

SQL> show user;

USER is "NEVA"

create user Biniam identified by biniam Default Tablespace Users Quota Unlimited On Users;

User BINIAM created.

create user eyasu identified by eyasu Default Tablespace Users Quota Unlimited On Users;

User EYASU created.

create user dawit identified by dawit Default Tablespace Users Quota Unlimited On Users;
User EYASU created.

User DAWIT created.

create user wuletaw identified by wuletaw Default Tablespace Users Quota Unlimited On Users;;

User WULETAW created.

14.Create roles
create role accountant;

Role ACCOUNTANT created.

create role customer;

Role CUSTOMER created.

create role manager;

Role MANAGER created.

create role casher;

Role CASHER created.

15.What is profile? Create profile.

SQL> CREATE PROFILE ACCOUNT_PROF LIMIT

2 FAILED_LOGIN_ATTEMPTS 5

3 PASSWORD_LIFE_TIME 30

4 PASSWORD_REUSE_TIME 40

5 PASSWORD_REUSE_MAX 6

6 PASSWORD_VERIFY_FUNCTION verify_function

7 PASSWORD_LOCK_TIME 2/24

8 PASSWORD_GRACE_TIME 20;

Profile created.

16
SQL> grant create session, Alter Database, Create Pluggable Database, Create Table, Create Any
Table, Alter Any Table, Drop Any Table, Lock Any Table, Select Any Table, Insert Any Table,
Update any table,Create Role, Drop Any Role, Grant Any Role, Create User, Alter User, Drop
User,create any view, create any trigger to manager;
Grant succeeded.
SQL> grant create session,Create Table, select any table,create any view to customer;
Grant succeeded.
SQL> grant create session, create table, select any table, create view ,drop any table, update any
table to casher;
Grant succeeded.

17-
SQL> grant manager to Biniam ;
Grant succeeded.
SQL> grant casher to eyasu;
Grant succeeded.
SQL> grant accountant to dawit;
Grant succeeded.
SQL> grant customer to wuletaw;
Grant succeeded.
SQL> connect biniam/biniam@localhost:1521/bms;
Connected.
SQL> show user;
USER is "BINIAM"

18
SQL> create table manager(managerid int primary key,firstname varchar(20),lastname
varchar(30) not null,age int ,
2 gender varchar(6)not null,birthofdate varchar(30),salary float);
Table created.
SQL> ALTER USER biniam QUOTA UNLIMiTED ON USERS;

User altered.
insert into manager (manID,fname,lname,age,gender,salary) values(1,'abebe',
'alemu',20,'male',1200.0);
1 row inserted.
SQL> create table managerphone(phonenumber int not null primary key,
2 managerid int,
3 foreign key(managerid) references manager(managerid)on delete cascade);
Table created.
SQL> create table manageraddress( city varchar(30) primary key,region varchar(20));
Table created.
SQL> insert into anageraddress values('funote','amhara');
1 row inserted.
SQL> create table accountant(
2 accountantid varchar(20) not null primary key,
3 firstname varchar(20) not null,lastname varchar(30) not null,
4 age int,gender varchar(6)not null,birthofdate date,
5 salary float);
Table created.

SQL> create table accountant(accountantid varchar(20) not null primary key,firstname varchar(20) not
null,lastname varchar(30) not null,age int,gender varchar(6)not null,birthofdate varchar(37),salary float);

Table created.

SQL> insert into accountant values('33','abay','ali',25,'male','2011-09-20',5000.00);

1 row created.

SQL> create table accountantphone(phonenumber int not null primary key,

2 accountantid varchar(20) ,

3 constraint pk_accountantid foreign key(accountantid) references accountant(accountantid)

4 on delete cascade);

Table created.
insert into accountantphone values(0912345678, '33');

1 row created.

SQL> create table accountantaddress(city varchar(30) not null primary key,region varchar(20) not null);

Table created.

SQL> insert into accountantaddress values('bahrdar','amhra');

1 row created.

SQL> insert into accountantaddress(city,region) values('bahredar','amhra');

1 row created.

SQL> select*from accountantaddress;

CITY REGION

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

bahrdar amhra

bahredar amhra

SQL> desc accountantaddress;

Name Null? Type

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

CITY NOT NULL VARCHAR2(30)

REGION NOT NULL VARCHAR2(20)

SQL> create table customer(customerid varchar(25) not null primary key,firstname varchar(20)not
null,lastname varchar(30)not null,age int,gender varchar(8) not null,birthofdate varchar(565));

Table created.

SQL> insert into customer


(customerid,firstname,lastname,age,gender,birthofdate)values('7','meseret','abebaw',50,'femal','1990-
11-13');

1 row created.

SQL> create table customerphoneno(phone varchar(30) not null primary key,

2 customerid varchar(4) ,

3 constraint fk_customerid foreign key(customerid) references customer(customerid) on delete


cascade );
Table created.

SQL> insert into customerphoneno( phone,customerid) values(0932165732,7);

1 row created.

SQL> create table customeraddress(city varchar(20) not null primary key,region varchar(20)not null);

Table created.

SQL> insert into customeraddress (city,region)values('debre merkos','amhara');

1 row created.

19
SQL> grant select,update,delete on manager to biniam with grant option;

Grant succeeded.

SQL> grant select,update,delete on accountant to wuletaw with grant option;

Grant succeeded.

SQL> grant select,update,delete on customer to eyasu with grant option;

Grant succeeded.

20

You might also like