Documente Academic
Documente Profesional
Documente Cultură
București, 2023
Page 1 of 23
Cerință proiect:
Baza de date proiectată are ca scop principal de a ţine evidenţa personalului unei instituţii în
ceea ce privește locația (clădire, cameră, etaj) în care își desfășoară activitatea, funcția pe care o
Această bază de date conține informații despre personalul angajat ( id, nume, cod
oraganizatoric, tip, sex, etaj, cameră, e-mail, marcă), structură organizatorică, postul
ocupat( denumire post), personal funcții ( nume, post, serviciu, clasă, grad profesional,
Page 2 of 23
SCHEMA BAZEI DE DATE
Page 3 of 23
CREAREA TABELELOR
Tabela LOCATIE
create table LOCATIE
(
ID_LOCATIE NUMBER not null,
DENUMIRE VARCHAR2(100),
ID_CLADIRE NUMBER,
ID_ETAJ NUMBER,
ID_CAMERA NUMBER
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela CLADIRE
create table CLADIRE
(
ID_CLADIRE NUMBER not null,
DENUMIRE VARCHAR2(100)
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela CAMERA
create table CAMERA
(
ID_CAMERA NUMBER not null,
DENUMIRE VARCHAR2(100)
)
Page 4 of 23
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela ETAJ
create table ETAJ
(
ID_ETAJ NUMBER not null,
DENUMIRE VARCHAR2(100)
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Page 5 of 23
Tabela PERSONAL
create table PERSONAL
(
ID_PERSONAL NUMBER(4) not null,
NUME VARCHAR2(50),
ORD VARCHAR2(10),
COD_SITE VARCHAR2(20) not null,
TIP VARCHAR2(1),
SEX VARCHAR2(1),
ETAJ NUMBER,
CAMERA NUMBER,
TELEFON VARCHAR2(15),
EMAIL VARCHAR2(50),
MARCA NUMBER
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
alter table PERSONAL
add constraint ID_PERSONAL_PK primary key (ID_PERSONAL)
using index
tablespace APEX
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 4M
next 4M
minextents 1
maxextents unlimited
);
alter table PERSONAL
add constraint PERSONAL_STRUCT_ORG_FK foreign key (COD_SITE)
references STRUCT_ORG (COD_SITE);
Page 6 of 23
Tabela POST
create table POST
(
ID_POST NUMBER not null,
DENUMIRE_POST VARCHAR2(100)
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela PERSONAL_FUNCTII
create table PERSONAL_FUNCTII
(
ID_PER_FUN NUMBER not null,
NUME NUMBER,
POST NUMBER,
SERVICIU VARCHAR2(300),
CLASA VARCHAR2(3),
GR_PROFESIONAL VARCHAR2(15),
GRADATIA NUMBER,
NR_ZILE_CONCEDIU NUMBER,
ORD NUMBER,
TIP VARCHAR2(2)
)
tablespace APEX
pctfree 10
Page 7 of 23
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela STRUCT_ORG
create table STRUCT_ORG
(
COD_SITE VARCHAR2(25) not null,
NIVEL NUMBER(2) not null,
SUP VARCHAR2(10),
ORD NUMBER(6),
Page 8 of 23
NUME VARCHAR2(100) not null,
NUME_SUP VARCHAR2(200)
)
tablespace APEX
pctfree 0
initrans 1
maxtrans 255
storage
(
initial 64K
next 4M
minextents 1
maxextents unlimited
);
Tabela CO
create table CO
(
ID_CO NUMBER not null,
NR_ZILE NUMBER,
DATA_INCEPUT DATE,
DATA_SFARSIT DATE,
PRELUAT_DE NUMBER,
NUME_PERSOANA NUMBER,
DATA_CO DATE,
NR_INREG NUMBER
)
tablespace APEX
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
Page 9 of 23
next 4M
minextents 1
maxextents unlimited
);
alter table CO
add constraint PK_CO primary key (ID_CO)
using index
tablespace APEX
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 4M
next 4M
minextents 1
maxextents unlimited
);
alter table CO
add constraint NUME_PERSOANA_FK foreign key (NUME_PERSOANA)
references PERSONAL (ID_PERSONAL);
alter table CO
add constraint PRELUAT_FK foreign key (PRELUAT_DE)
references PERSONAL (ID_PERSONAL);
Page 10 of 23
Modificarea coloanei id_post în tabela PERSONAL:
ALTER TABLE personal modify id_post number(1);
Comanda Scop
INSERT Adauga o noua inregistrare in tabela
UPDATE Modifica valorile unor inregistrari din tabele
DELETE Sterge inregistrari din tabele
MERGE Actualizeaza o tabela in functie de anumite conditii
SELECT Regaseste inregistrari in tabele sau vederi (view).
Page 11 of 23
Adăugare înregistrare în tabela PERSONAL:
INSERT INTO personal(id_personal,nume,ord,cod_site,etaj,camera,telefon,marca) VALUES
(6,'Costoiu','EUBAM','DGV',4,80,318,6900);
SELECT * FROM personal;
Page 12 of 23
SELECT * FROM co;
Page 13 of 23
Ștergerea numelui al cărui ID are valoarea 6 în tabela PERSONAL. Să se anukeze
tranzacția:
INTEROGAREA TABELELOR
Selectarea numelor care au inclusă litera “B” în numele lor din tabela PERSONAL:
Page 14 of 23
Selectare minim data început și maxim data sfârșit din tabela CO:
SELECT MIN(data_inceput), MAX(data_sfarsit) FROM co;
Page 15 of 23
Afişare numărului distinct de coduri din tabela PERSONAL:
Afişarea structurilor organizatorice( nume și cod) descrescător după nivel din tabela
STRUCT_ORG:
SELECT nume, cod_site
FROM struct_org
ORDER BY nivel DESC ;
Page 16 of 23
Afişarea cererilor de concediu începute în lunile ianuarie și februarie din tabela CO:
Afişarea personalului care lucrează pe un etaj superior etajului unde se află camera
numărul 55 din tabela PERSONAL:
SELECT nume, camera,etaj
FROM personal
WHERE etaj>ANY
(SELECT etaj FROM personal where camera=55);
Page 17 of 23
SELECT id_locatie, l.denumire,c.denumire FROM locatie l
INNER JOIN cladire c on l.id_cladire=c.id_cladire;
Page 18 of 23
INTEROGĂRI IERARHICE
Page 19 of 23
GESTIUNEA TABELELOR, VEDERI, SINONIME, INDECŞI, SECVENŢE
Page 20 of 23
create sequence LOCATIE_SEQ
minvalue 1
maxvalue 9999999999999999999999999999
start with 321
increment by 1
cache 20;
Page 22 of 23
SPARE2 NUMBER,
SPARE3 NUMBER,
SPARE4 VARCHAR2(1000),
SPARE5 VARCHAR2(1000),
SPARE6 DATE,
SPARE7 VARCHAR2(4000),
SPARE8 VARCHAR2(4000),
SPARE9 NUMBER,
SPARE10 NUMBER,
SPARE11 TIMESTAMP(6)
)
cluster C_USER# ();
Page 23 of 23