0% found this document useful (0 votes)
44 views2 pages

TP 1

This document contains Oracle SQL scripts that: 1) Unlock the HR user account and view their tables. 2) Define functions and procedures to count and list objects and tables accessible to a given user. 3) Call the functions and procedures, passing the user 'HR' as a parameter to output the results.

Uploaded by

Yalla Habibi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

TP 1

This document contains Oracle SQL scripts that: 1) Unlock the HR user account and view their tables. 2) Define functions and procedures to count and list objects and tables accessible to a given user. 3) Call the functions and procedures, passing the user 'HR' as a parameter to output the results.

Uploaded by

Yalla Habibi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

--dévérouiller HR

/*
connect sys as sysdba
ALTER USER hr identified by hr
ACCOUNT UNLOCK;
connect hr/hr
select table_name FROM user_tables;
*/
--Correction TP1 DBA
--1
/*
select * from dict
order by table_name;
*/
--2
/*
select username, created
From dba_users;
*/
--3
/*
select username, type from v$session
where TYPE= 'USER';
*/
--4
/*
select table_name , comments
from dict Where table_name like '%SGA%';
*/
--Select SUM(value) from v$SGA;
--5
/*
select object_name, object_type,
created,last_ddl_time
from user_objects;
*/
--6
--select table_name, owner from
--all_tables;
--7
/*
CREATE OR REPLACE PROCEDURE
proc_tab_list
IS
BEGIN
for i in (select table_name A
from user_tables )
LOOP
dbms_output.put_line(i.A);
END LOOP;
END;
/
*/
--8
--Select count(*) from dba_tables;
--ou
--Select count(*) from all_tables;
--9
/*
Select count(*) from all_tables
WHERE owner='HR';
*/
--10
/*
CREATE OR REPLACE FUNCTION fn_nbr_objet
(utilisateur varchar2)
RETURN integer
IS
nbr integer;
BEGIN
Select count(*)
INTO nbr
FROM dba_objects WHERE Owner =
UPPER(utilisateur);
Return nbr;
END;
/
*/
-- APPEL
/*
Begin
dbms_output.put_line(fn_nbr_objet('hr'));
end;
/
*/
--SELECT fn_nbr_objet('hr') from dual;
--11
/*
CREATE OR REPLACE PROCEDURE proc_tab_list
(utilisateur in out varchar2)
IS
nb integer:=0;
BEGIN
for i in (select * from all_tables
where owner =UPPER(utilisateur))
LOOP
dbms_output.put_line(i.table_name);
nb:=nb+1;
END LOOP;
utilisateur :=nb;
END;
/
*/
--APPEL
--execute proc_tab_list('hr')
DECLARE
b varchar2(4) :='hr';
BEGIN
proc_tab_list(b);
dbms_output.put_line(b);
END;
/

You might also like