Grosse MàJ
This commit is contained in:
BIN
G51/ExerciceAccesConcurrentsGestionTransaction.xls
Normal file
BIN
G51/ExerciceAccesConcurrentsGestionTransaction.xls
Normal file
Binary file not shown.
BIN
G51/LicenceTP01.pdf
Normal file
BIN
G51/LicenceTP01.pdf
Normal file
Binary file not shown.
84
G51/TD01.texte
Normal file
84
G51/TD01.texte
Normal file
@ -0,0 +1,84 @@
|
||||
+ NOTES :
|
||||
---------
|
||||
|
||||
+ Connexion depuis notre poste sur Oracle :
|
||||
sqlplus trois_dossmanno@lpdt
|
||||
+ Adresse de la documentation d'Oracle :
|
||||
http://www.oracle.com/global/fr/support/index.html
|
||||
+ Ceci permet d'aggrandir la longueur de la ligne dans SQLPLUS :
|
||||
set linesize 255
|
||||
+ Enlever les entêtes de colonne
|
||||
set heading off
|
||||
*Afficher les champs de la table V$INSTANCE
|
||||
desc V$INSTANCE;
|
||||
|
||||
* Sauvegarde dans un fichier la commande
|
||||
save tssize
|
||||
* Défini l'éditeur par défaut
|
||||
define_editor=vim
|
||||
* Editer le fichier
|
||||
ed tssize
|
||||
* Lance ledit fichier
|
||||
@tssize
|
||||
|
||||
+ EXERCICE :
|
||||
------------
|
||||
|
||||
CREATION UTILISATEURS :
|
||||
-----------------------
|
||||
create user litt
|
||||
identified by litt
|
||||
default tablespace USERS
|
||||
temporary tablespace TEMP;
|
||||
|
||||
create user trois_dossmanno
|
||||
identified by olivier
|
||||
default tablespace USERS
|
||||
temporary tablespace TEMP;
|
||||
|
||||
DROITS SUR BASE :
|
||||
-----------------
|
||||
grant DBA to litt;
|
||||
|
||||
grant DBA to trois_dossmanno;
|
||||
|
||||
* Affiche la date pour l'utilisateur courant.
|
||||
select 'Date du jour : '|| to_char(sysdate, 'DD/MM/YYYY') " " from dual;
|
||||
|
||||
INSTANCE EN COURS :
|
||||
-------------------
|
||||
|
||||
select INSTANCE_NAME, INSTANCE_NAME "IDENTIFIANT", VERSION, HOST_NAME "SERVEUR", CREATED "CREATION", STARTUP_TIME "DEMARRAGE", STATUS "STATUT" from V$INSTANCE
|
||||
|
||||
TABLESPACE :
|
||||
------------
|
||||
|
||||
* Affiche l'ensemble des tablespaces :
|
||||
select * from dba_tablespaces;
|
||||
|
||||
* Afficher les détails des tablespaces
|
||||
select ut.tablespace_name "Tablespace", ut.status "Statut", df.file_name "Fichier(s)", df.status "Statut" from user_tablespaces ut,dba_data_files df;
|
||||
|
||||
AFFICHER QUELQUES DONNES SUR LA TABLE SYSTEM :
|
||||
-----------------------------------------------
|
||||
|
||||
select * from dba_free_space fs, dba_data_files df where fs.tablespace_name = df.tablespace_name and fs.tablespace_name = 'SYSTEM';
|
||||
|
||||
*TOTAL maximum
|
||||
select tablespace_name, to_char(SUM(BYTES)/1048579,'999D000') "Total MB"
|
||||
from dba_data_files
|
||||
group by tablespace_name
|
||||
|
||||
* Affiche la mémoire utilisée pour chacune des tables
|
||||
select df.tablespace_name, to_char((SUM(fs.BYTES)+SUM(df.BYTES))/1048579,'999D00') "Total MB", to_char(SUM(fs.BYTES)/1048579,'999D00') "Libre MB" , to_char(SUM(df.BYTES)/1048579, '999D00') "Utilise MB"
|
||||
from dba_data_files df, dba_free_space fs
|
||||
where df.tablespace_name = fs.tablespace_name
|
||||
group by df.tablespace_name
|
||||
|
||||
|
||||
CREER un table space :
|
||||
----------------------
|
||||
|
||||
create tablespace VAL_DOSS datafile '/opt/oralp/LPDT/tablespaces/data/VAL_DOSS.dbf' size 1m reuse autoextend off;
|
||||
|
||||
|
172
G51/TD02.texte
Normal file
172
G51/TD02.texte
Normal file
@ -0,0 +1,172 @@
|
||||
|
||||
Aller sur pipit/~tancrez/
|
||||
pour avoir le sujet.
|
||||
|
||||
TD02 :
|
||||
|
||||
Création des tables :
|
||||
|
||||
|
||||
create table film (
|
||||
id_film number(4) PRIMARY KEY,
|
||||
titre varchar(255),
|
||||
annee number(6),
|
||||
id_realisateur varchar(255)
|
||||
)
|
||||
TABLESPACE USERS;
|
||||
|
||||
create table seance (
|
||||
id_seance number(4) PRIMARY KEY,
|
||||
heuredebut number(4),
|
||||
heurefin number(4),
|
||||
id_salle number(4),
|
||||
id_film number(4)
|
||||
|
||||
create table cinema (
|
||||
id_cinema number(4) PRIMARY KEY,
|
||||
nom varchar(255),
|
||||
adresse varchar(255)
|
||||
)
|
||||
TABLESPACE USERS;
|
||||
|
||||
create table salle (
|
||||
id_salle number(4) PRIMARY KEY,
|
||||
nom varchar(255),
|
||||
capacite number(3),
|
||||
id_cinema number(4)
|
||||
)
|
||||
TABLESPACE USERS;
|
||||
|
||||
ALTER TABLE salle
|
||||
ADD CONSTRAINT f_id_cinema FOREIGN KEY (id_cinema) REFERENCES cinema(id_cinema);
|
||||
|
||||
)
|
||||
|
||||
ALTER TABLE seance
|
||||
ADD CONSTRAINT f_id_salle FOREIGN KEY (id_salle) REFERENCES salle(id_salle);
|
||||
|
||||
ALTER TABLE seance
|
||||
ADD CONSTRAINT f_id_film FOREIGN KEY (id_film) REFERENCES film(id_film);
|
||||
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
AIDE AIDE AIDE AIDE AIDE
|
||||
|
||||
http://www.toutenligne.com/index.php?contenu=sql_explain&menu=sql
|
||||
|
||||
|
||||
Aller aussi sur : http://pipit/~3fheitz
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|
||||
create table PLAN_TABLE (
|
||||
statement_id varchar2(30),
|
||||
timestamp date,
|
||||
remarks varchar2(80),
|
||||
operation varchar2(30),
|
||||
options varchar2(30),
|
||||
object_node varchar2(128),
|
||||
object_owner varchar2(30),
|
||||
object_name varchar2(30),
|
||||
object_instance numeric,
|
||||
object_type varchar2(30),
|
||||
optimizer varchar2(255),
|
||||
search_columns number,
|
||||
id numeric,
|
||||
parent_id numeric,
|
||||
position numeric,
|
||||
cost numeric,
|
||||
cardinality numeric,
|
||||
bytes numeric,
|
||||
other_tag varchar2(255),
|
||||
partition_start varchar2(255),
|
||||
partition_stop varchar2(255),
|
||||
partition_id numeric,
|
||||
other long,
|
||||
distribution varchar2(30))
|
||||
tablespace USERS
|
||||
;
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
set linesize 255
|
||||
set wrap on
|
||||
col acces for a20
|
||||
col object_name for a10
|
||||
select id, lpad(' ',parent_id+1)||operation acces,options,object_name,parent_id,position
|
||||
from plan_table where statement_id ='MonPremierEssai';
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
ensuite taper la commande suivante :
|
||||
|
||||
explain plan
|
||||
set statement_id ='MonPremierEssai'
|
||||
for
|
||||
select * from cinema where nom='Le rex'
|
||||
;
|
||||
|
||||
Pour finalement vérifier le contenu ainsi générer :
|
||||
|
||||
select operation,options,object_name,id,parent_id,position
|
||||
from plan_table
|
||||
where statement_id='MonPremierEssai' order by id
|
||||
;
|
||||
|
||||
CE QUI DONNE :
|
||||
|
||||
OPERATION OPTIONS OBJECT_NAME ID PARENT_ID POSITION
|
||||
------------------------------ ------------------------------ ------------------------------ ---------- ---------- ----------
|
||||
SELECT STATEMENT 0
|
||||
TABLE ACCESS FULL CINEMA 1 0 1
|
||||
|
||||
|
||||
¤ Pour question 2 on a :
|
||||
|
||||
explain plan
|
||||
set statement_id ='MonSecondEssai'
|
||||
for
|
||||
SELECT * FROM cinema WHERE id_cinema=1908;
|
||||
|
||||
set linesize 255
|
||||
set wrap on
|
||||
col acces for a20
|
||||
col object_name for a10
|
||||
select id, lpad(' ',parent_id+1)||operation acces,options,object_name,parent_id,position
|
||||
from plan_table where statement_id ='MonSecondEssai';
|
||||
|
||||
¤ Ce qui donne :
|
||||
|
||||
ID ACCES OPTIONS OBJECT_NAM PARENT_ID POSITION
|
||||
---------- -------------------- ------------------------------ ---------- ---------- ----------
|
||||
0 SELECT STATEMENT
|
||||
1 TABLE ACCESS BY INDEX ROWID CINEMA 0 1
|
||||
2 INDEX UNIQUE SCAN SYS_C00243 1 1
|
||||
9
|
||||
|
||||
¤ Pour les jointures on a :
|
||||
|
||||
explain plan
|
||||
set statement_id ='MonTroisiemeEssai'
|
||||
for
|
||||
SELECT cinema.nom, capacite
|
||||
FROM cinema, salle WHERE cinema.id_cinema=salle.id_cinema;
|
||||
|
||||
set linesize 255
|
||||
set wrap on
|
||||
col acces for a20
|
||||
col object_name for a10
|
||||
select id, lpad(' ',parent_id+1)||operation acces,options,object_name,parent_id,position
|
||||
from plan_table where statement_id ='MonTroisiemeEssai';
|
||||
|
||||
¤ Ce qui donne :
|
||||
|
||||
ID ACCES OPTIONS OBJECT_NAM PARENT_ID POSITION
|
||||
---------- -------------------- ------------------------------ ---------- ---------- ----------
|
||||
0 SELECT STATEMENT
|
||||
1 NESTED LOOPS 0 1
|
||||
2 TABLE ACCESS FULL SALLE 1 1
|
||||
3 TABLE ACCESS BY INDEX ROWID CINEMA 1 2
|
||||
4 INDEX UNIQUE SCAN SYS_C00243 3 1
|
||||
9
|
||||
|
Reference in New Issue
Block a user