Data Base 2

You might also like

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

SQL> connect sys/welcome as sysdba;

Connected.
SQL> create tablespace human_resources datafile 'hr1.dbf' size 20m, 'hr2.dbf' size
30m;

Tablespace created.

SQL> create tablespace loan_managment datafile 'lm1.dbf' size 30m, 'lm2.dbf' size
40m;

Tablespace created.

SQL> create tablespace marketing datafile 'mr1.dbf' size 20m;

Tablespace created.

SQL> create profile profile12 LIMIT


2 sessions_per_user 2
3 password_life_time 30
4 password_lock_time 3
5 failed_login_attempts 4;

Profile created.

SQL> create profile profile3 LIMIT


2 sessions_per_user 3
3 password_life_time 20
4 password_lock_time 3
5 failed_login_attempts 3;

Profile created.

SQL> create role r1;

Role created.

SQL> create role r2;

Role created.

SQL> create role r3;

Role created.

SQL> create user hrr


2 identified by hr123
3 default tablespace human_resources
4 TEmporary tablespace TEMP
5 profile default
6 account unlock;

User created.

SQL> create user lmm


2 identified by lm123
3 default tablespace loan_managment
4 TEmporary tablespace TEMP
5 profile default
6 account unlock;

User created.

SQL> create user mrr


2 identified by mr123
3 default tablespace marketing
4 TEmporary tablespace TEMP
5 profile default
6 account unlock;

User created.

SQL> alter user hrr profile profile12;

User altered.

SQL> alter user lmm profile profile12;

User altered.

SQL> alter user mrr profile profile3;

User altered.

SQL> grant all privileges to r1;

Grant succeeded.

SQL> grant r1 to hrr;

Grant succeeded.

SQL> grant create session, connect, create table, resource, select any table to r2;

Grant succeeded.

SQL> grant create session, connect, create table, resource, select any table to r3;

Grant succeeded.

SQL> grant r2 to lmm;

Grant succeeded.

SQL> grant r3 to mrr;

Grant succeeded.

SQL> connect hrr/hr123;


Connected.
SQL> create table data_employee (
2 id number(10) primary key,
3 name varchar(15),
4 date_first varchar(17),
5 rank varchar(5),
6 notes varchar(88));

Table created.

SQL> create table employee_date (


2 id number(10),
3 datef varchar(10),
4 datee varchar(19),
5 free varchar(22),
6 foreign key(id) references data_employee (id));

Table created.

SQL> connect lmm/lm123;


Connected.

SQL> create table customer (


2 id number(10) primary key,
3 name_customer varchar(20));

Table created.

SQL> create table loan (


2 firstdate varchar(12),
3 endfirst varchar(13),
4 type varchar(12),
5 foreign key(id) references customer (id));

Table created.

SQL> alter table loan add (id_loan number(10) primary key);

Table altered.

SQL> grant references on lmm.loan to mrr;

Grant succeeded.

SQL> create table adver (


2 id number(12) primary key,
3 id_loan number(10),
4 name_adver varchar(12),
5 cost_adver number(12),
6 date_adverr varchar(12),
7 foreign key(id_loan) references lmm.loan (id_loan));

Table created.

You might also like