Professional Documents
Culture Documents
GROUP2 Oracle
GROUP2 Oracle
15063]
(c) 2017 Microsoft Corporation. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing
options
Session altered.
SQL> drop user ADMIN;
User dropped.
User created.
SQL> show user;
USER is "SYS"
SQL> drop user ADMIN;
User dropped.
User created.
Grant succeeded.
User created.
User created.
User created.
SQL> create user Mr_Kifile identified by kifile;
User created.
Role created.
Role created.
Role created.
Role created.
Role created.
Grant succeeded.
Revoke succeeded.
SQL>
SQL> create table REGISTERAR
(regID varchar(30) primary key,
Rname varchar(30),
Ryear varchar(20));
Table created.
1 row created.
1 row created.
1 row created.
REGID RNAME
------------------------------ ------------------------------
RLOCATION
------------------------------
10 CIR
first floor
11 EIR
second floor
12 BIR
third floor
SQL>
Table created.
SQL> INSERT into DEPARTMENT values('20','IS','Second floor','10');
1 row created.
1 row created.
1 row created.
1 row created.
DEPID DEP_NAME
------------------------------ ------------------------------
DEP_LOCATION REGID
------------------------------ ------------------------------
20 IS
Second floor 10
21 CS
Second floor 11
22 SE
Second floor 12
DEPID DEP_NAME
------------------------------ ------------------------------
DEP_LOCATION REGID
------------------------------ ------------------------------
23 IT
Second floor 10
SQL>
SQL> create table COURSE
( coursecode varchar(30) primary key,
courseName varchar(30),
credithour varchar(30),
coursetype varchar(30),
depID varchar(30),constraint fk_depID foreign key(depID) references
DEPARTMENT(depID));
Table created.
1 row created.
1 row created.
1 row created.
COURSECODE COURSENAME
------------------------------ ------------------------------
CREDITHOUR COURSETYPE
------------------------------ ------------------------------
DEPID
------------------------------
INSY2031 C#
7 major
21
INSY2033 ADBMS
6 major
20
COURSECODE COURSENAME
------------------------------ ------------------------------
CREDITHOUR COURSETYPE
------------------------------ ------------------------------
DEPID
------------------------------
INSY2032 Networking
5 major
20
Table dropped.
Table created.
1 row created.
1 row created.
1 row created.
SQL>
SQL> select *from COURSE;
COURSECODE COURSENAME
------------------------------ ------------------------------
CREDITHOUR COURSETYPE
------------------------------ ------------------------------
DEPID
------------------------------
INSY2033 C#
7 major
21
INSY3071 Networking
5 major
20
COURSECODE COURSENAME
------------------------------ ------------------------------
CREDITHOUR COURSETYPE
------------------------------ ------------------------------
DEPID
------------------------------
INSY2062 ADBMS
6 major
20
SQL>
SQL>
SQL> create table INSTRACTOR
(instID varchar(30) primary key,
fname varchar(30),
lname varchar(30),
gender varchar(30),
salary float,
birthdate date,
depId varchar(30) ,foreign key(depId) references DEPARTMENT(depID));
Table created.
1 row created.
1 row created.
1 row created.
INSTID FNAME
------------------------------ ------------------------------
LNAME GENDER SALARY
------------------------------ ------------------------------ ----------
BIRTHDATE AGE DEPID
--------- ---------- ------------------------------
100 Habite
legebo M 3000
01-SEP-95 22 20
101 Zeru
Kelete M 5000
02-APR-95 22 22
INSTID FNAME
------------------------------ ------------------------------
LNAME GENDER SALARY
------------------------------ ------------------------------ ----------
BIRTHDATE AGE DEPID
--------- ---------- ------------------------------
102 Amare
kebede M 4000
02-MAY-85 22 20
SQL>
SQL> create table INSTRACTOR_PHONE
2 (
3 phoneID int primary key ,
4 phone varchar(30),
5 instID varchar(30), foreign key(instID) references INSTRACTOR(instID));
Table created.
1 row created.
1 row created.
1 row created.
SQL>
Table created.
1 row created.
SQL> insert into STUDENT VALUES('CIR/332/09','yenesew','Mola','F',3.90,'1 sep
2000',19,'B','third year','20','10');
1 row created.
1 row created.
1 row created.
STUDID FNAME
------------------------------ ------------------------------
LNAME S GPA BIRTHDATE AGE S YEARE
------------------------------ - ---------- --------- ---------- - ----------
DEPID REGID
------------------------------ ------------------------------
CIR/100/08 sara
zeru F 3.9 10-MAY-90 20 A third year
22 11
CIR/332/09 yenesew
Mola F 3.9 01-SEP-00 19 B third year
20 10
STUDID FNAME
------------------------------ ------------------------------
LNAME S GPA BIRTHDATE AGE S YEARE
------------------------------ - ---------- --------- ---------- - ----------
DEPID REGID
------------------------------ ------------------------------
CIR/073/09 Bini
Tesfaye M 3.92 01-JUL-00 22 B third year
21 11
CIR/160/10 abebe
zola M 3 10-MAY-00 22 D first year
STUDID FNAME
------------------------------ ------------------------------
LNAME S GPA BIRTHDATE AGE S YEARE
------------------------------ - ---------- --------- ---------- - ----------
DEPID REGID
------------------------------ ------------------------------
22 11
SQL>
SQL> create table STUDENT_PHONE
(
phoneID int primary key ,
phoneno varchar(30),
studID varchar(30) ,foreign key(studID ) references STUDENT(studID) );
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
SQL>
SQL> select * from STUDENT_PHONE;
SQL>
SQL> create table studentinstructorcourse_JUNCTION
(
studID varchar(30), foreign key(studID) references STUDENT(studID),
instID varchar(30), foreign key(instID) references INSTRACTOR(instID),
courseCode varchar(30), foreign key(courseCode) references
COURSE(courseCode),
constraint PKInsStuCour primary key (InstID, StudID,CourseCode));
Table created.
SQL> drop table STUDENT_JUNCTION;
Table dropped.
Table created.
SQL> insert into STUDENT_JUNCTION values('CIR/332/09','101','INSY3071');
1 row created.
1 row created.
////////////////////////////////////////////////////////////////
Profile created.
SQL>
/////////////////////////////////
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 to president;
Grant succeeded.
SQL> grant grant create session,create table,select any table,create view ,drop any
table,update any table to dean;
Grant succeeded.
SQL> grant grant create session,create table,select any table,create view ,drop any
table,update any table ,create session to head;
Grant succeeded.
SQL> grant grant create session,create table,select any table,create view ,drop any
table,update any table ,create session to dean;
Grant succeeded.
SQL> grant create session,select any table,create view ,create session to student;
Grant succeeded.
SQL> grant create session,create table,select any table,create view ,create session
to instractor;
Grant succeeded.
SQL>
SQL> GRANT DBA to ADMIN with ADMIN option;
Grant succeeded.
SQL> connect ADMIN/admin@pdborcl;
Connected.
SQL> show user;
USER is "ADMIN"
SQL>
SQL> grant select,update,delete on Mr_kifile.Student to head;
Grant succeeded.
SQL> grant select,update,delete on Mr_kifile.Course to head;
Grant succeeded.
SQL> grant head to Mr_amare;
Grant succeeded.
SQL> grant select,update,delete on Mr_kifile.Course to instractor;
Grant succeeded.
SQL> grant select,update,delete on Mr_kifile.student to instractor;
Grant succeeded.
SQL> grant instractor to Mr_worku;
Grant succeeded.
SQL> grant select,update,delete on Mr_kifile.student to student;
Grant succeeded.
SQL> grant student to biniam;
Grant succeeded.
////////////////////////////////////////////////////
Trigger created.
Trigger created.
Trigger created.
Trigger created.
Trigger created.
//////////////////////////////////////////////////////
Table created.
//////////////////////////////audit student
SQL> Create table Student_Audit(
2 New_Name varchar2(30),
3 Old_Name varchar2(50),
4 User_Name varchar2(20),
5 Entry_Date varchar2(80),
6 Operation varchar2(30)
7 );
Table created.
//////////////////////////////audit trigger
SQL> Create or replace trigger BeIUD_Student
2 Before Insert or Update or Delete on Student
3 For each row
4 Enable
5 Declare
6 V_user varchar2(60);
7 V_date varchar2(70);
8 Begin
9 select user, to_CHAR (Sysdate, 'DD/MoN/YYY HH24:MI:SS')into V_user, V_date
from
10 Dual;
11 If Inserting Then
12 Insert into Student_Audit(New_Name, Old_Name, User_Name, Entry_Date,
Operation)
13 Values(:New.Fname, Null, V_user, V_date, 'Insert');
14 ElsIf Updating Then
15 Insert into Student_Audit(New_Name, Old_Name, User_Name, Entry_Date,
Operation)
16 Values(:New.Fname, :Old.Fname, V_user, V_date, 'Update');
17 ElsIf Deleting Then
18 Insert into Student_Audit(New_Name, Old_Name, User_Name, Entry_Date,
Operation)
19 Values(Null, :Old.Fname, V_user, V_date, 'Delete');
20 End If;
21 end;
22 /
Trigger created.
SQL>
/////////////////////////////////////24.by schema audit
SQL> Create Table Schema_Audit (
2 DDL_Date Date,
3 DDL_User Varchar(30),
4 Object_Created Varchar(40),
5 Object_Name Varchar(40),
6 DDL_Operation Varchar(60)
7 );
Table created.
SQL>
/////////////////////////////////////////////--HR Schema Audit
Audit succeeded.
Audit succeeded.
Audit succeeded.
Audit succeeded.
Table created.
Trigger created.