Vous êtes sur la page 1sur 12

Exercice 1

 à partir de cmd:
o sqlplus / as sysdba
o ou sqlplus /nolog puis connect / as sysdba;
 à partir de sqlplus:
o system/oracle11g puis connect / as sysdba
1. startup open;
2. nn, startup force mount;
3. shutdown normal;
Exercice 2
1. Consulter le schéma du dictionnaire DICT et préciser le rôle de chacun de ses attributs.
describe dict;
Les descriptions des objets sont accessibles via une vue nommée « DICTIONARY ». Cette vue, également accessible via le synonyme public « DICT », interroge la base de
données pour déterminer à quelles vues du dictionnaire vous pouvez accéder. Elle recherche également les synonymes publics définis pour ces vues.

2. Visualiser le contenu complet du dictionnaire DICT à l'aide de la commande de sélection SELECT.


select * from dict; (where rownum <=20)

3. Identifier le rôle et la structures des tables ou des vues suivantes : ALL_CATALOG, ALL_USERS, ALL_COL_COMMENTS, ALL_VIEWS, USER_TABLES, USER_CATALOG. En
vous aidant le cas échéant du contenu de la table ALL_COL_COMMENTS ou de la documentation Oracle; donner succinctement le rôle de chaque attribut de ces tables.
 ALL_CATALOG: tous les tables, views, synonyms, sequences accessible à l'utilisateur
 ALL_USERS: Informations sur tous les utilisateurs de la base de données
 ALL_COL_COMMENTS: Commentaires sur les colonnes des vues et des tables accessibles par l'utilisateurs
 ALL_CONSTRAINTS: Liste des contraintes sur les tables accessible par l'utilisateur
 ALL_VIEWS: Description des vues accessible / utilisateur
 USER_TABLES: Description des tables possédées par l'utilisateur
 USER_CATALOG: Liste des indexes, tables, vues, clusters, synonymes et séquences possédés par l'utilisateur
4. Donner le rôle et la structure des tables (ou vues) suivantes : ALL_CONSTRAINTS, ALL_CONS_COLUMNS. Quels sont les types de contraintes reconnues par Oracle ?

ALL_CONSTRAINTS : describes constraint definitions on tables accessible to the current user

select distinct(constraint_type) from all_constraints;

Column Datatype NULL Description

OWNER VARCHAR2(30) NOT Owner of the constraint definition


NULL

CONSTRAINT_NAME VARCHAR2(30) NOT Name of the constraint definition


NULL

CONSTRAINT_TYPE VARCHAR2(1) Type of constraint definition:


 C (check constraint on a table)
 P (primary key)
 U (unique key)
 R (referential integrity)
 V (with check option, on a view)
 O (with read only, on a view)

TABLE_NAME VARCHAR2(30) NOT Name associated with the table (or view) with constraint definition
NULL

SEARCH_CONDITION LONG Text of search condition for a check constraint

R_OWNER VARCHAR2(30) Owner of table referred to in a referential constraint

R_CONSTRAINT_NAME VARCHAR2(30) Name of the unique constraint definition for referenced table

DELETE_RULE VARCHAR2(9) Delete rule for a referential constraint (CASCADE or NO ACTION)


Column Datatype NULL Description

STATUS VARCHAR2(8) Enforcement status of constraint (ENABLED or DISABLED)

DEFERRABLE VARCHAR2(14) Whether the constraint is deferrable

DEFERRED VARCHAR2(9) Whether the constraint was initially deferred

VALIDATED VARCHAR2(13) Whether all data obeys the constraint (VALIDATED or NOT VALIDATED)

GENERATED VARCHAR2(14) Whether the name of the constraint is user or system generated

BAD VARCHAR2(3) A YES value indicates that this constraint specifies a century in an ambiguous manner. To avoid errors resulting from
this ambiguity, rewrite the constraint using the TO_DATE function with a four-digit year.

See Also: the TO_DATE function inOracle Database SQL Referenceand Oracle Database Application Developer's Guide -
Fundamentals

RELY VARCHAR2(4) Whether an enabled constraint is enforced or unenforced.

See Also: the constraints inOracle Database SQL Reference

LAST_CHANGE DATE When the constraint was last enabled or disabled

INDEX_OWNER VARCHAR2(30) Name of the user owning the index

INDEX_NAME VARCHAR2(30) Name of the index (only shown for unique and primary-key constraints)

INVALID VARCHAR2(7) Whether the constraint is invalid

VIEW_RELATED VARCHAR2(14) Whether the constraint depends on a view

Type of constraint definition:


 C (check constraint on a table)
 P (primary key)
 U (unique key)
 R (referential integrity)
 V (with check option, on a view)
 O (with read only, on a view)

ALL_CONS_COLUMNS describes columns that are accessible to the current user and that are specified in constraints.

Column Datatype NULL Description

OWNER VARCHAR2(30) NOT Owner of the constraint definition


NULL

CONSTRAINT_NAME VARCHAR2(30) NOT Name of the constraint definition


NULL

TABLE_NAME VARCHAR2(30) NOT Name of the table with the constraint definition
NULL

COLUMN_NAME VARCHAR2(4000) Name of the column or attribute of the object type column specified in the constraint definition

Note: If you create a constraint on a user-defined REF column, the system creates the constraint on the attributes that
make up the REF column. Therefore, the column names displayed in this view are the attribute names, with
the REF column name as a prefix, in the following form:

"REF_name"."attribute"

POSITION NUMBER Original position of the column or attribute in the definition of the object

5. Quels sont les différents types d'objets standards (attribut TABLE_TYPE) reconnus par Oracle dans son catalogue ?
select distinct(Table_type) from all_catalog;
6. Donner le rôle et le schéma de relation correspondant à la table USER_USERS. Quel est votre nom d'utilisateur Oracle ?
USER_USERS describes the current user. Its columns (except for PASSWORD and PROFILE) are the same as those in DBA_USERS.
select user_name from user_users;
7. Comparer le contenu des tables ALL_CATALOG et USER_CATALOG. Commentaires ?
all catalog contient: owner, table_name, table_type
all_catalog posséde un attribut additionnel % à all_catalog qui est owner

8. Retrouvez le nom de l’instance Oracle, sa version, la machine hôte et l’état de la base (v$instance).
select instance_name,version, host_name,status from v$instance;

Column Datatype Description

INSTANCE_NUMBER NUMBER Instance number used for instance registration (corresponds to the INSTANCE_NUMBERinitialization parameter)

See Also: "INSTANCE_NUMBER"

INSTANCE_NAME VARCHAR2(16) Name of the instance

HOST_NAME VARCHAR2(64) Name of the host machine

VERSION VARCHAR2(17) Database version

STARTUP_TIME DATE Time when the instance was started


Column Datatype Description

STATUS VARCHAR2(12) Status of the instance:

 STARTED - After STARTUP NOMOUNT


 MOUNTED - After STARTUP MOUNT orALTER DATABASE CLOSE
 OPEN - After STARTUP or ALTER DATABASE OPEN
 OPEN MIGRATE - After ALTER DATABASE OPEN { UPGRADE | DOWNGRADE }

PARALLEL VARCHAR2(3) Indicates whether the instance is mounted in cluster database mode (YES) or not (NO)

THREAD# NUMBER Redo thread opened by the instance

ARCHIVER VARCHAR2(7) Automatic archiving status:

 STOPPED
 STARTED
 FAILED - Archiver failed to archive a log last time but will try again within 5 minutes

LOG_SWITCH_WAIT VARCHAR2(15) Event that log switching is waiting for:

 ARCHIVE LOG
 CLEAR LOG
 CHECKPOINT
 NULL - ALTER SYSTEM SWITCH LOGFILE is hung but there is room in the current online redo log

LOGINS VARCHAR2(10) Indicates whether the instance is in unrestricted mode, allowing logins by all users (ALLOWED, or in restricted
mode, allowing logins by database administrators only (RESTRICTED)
Column Datatype Description

SHUTDOWN_PENDING VARCHAR2(3) Indicates whether a shutdown is pending (YES) or not (NO)

DATABASE_STATUS VARCHAR2(17) Status of the database:

 ACTIVE
 SUSPENDED
 INSTANCE RECOVERY

INSTANCE_ROLE VARCHAR2(18) Indicates whether the instance is an active instance (PRIMARY_INSTANCE) or an inactive secondary instance
(SECONDARY_INSTANCE), or UNKNOWN if the instance has been started but not mounted

ACTIVE_STATE VARCHAR2(9) Quiesce state of the instance:

 NORMAL - Database is in a normal state.


 QUIESCING - ALTER SYSTEM QUIESCE RESTRICTED has been issued: no new user transactions, queries, or
PL/SQL statements are processed in this instance. User transactions, queries, or PL/SQL statements issued before
theALTER SYSTEM QUIESCE RESTRICTEDstatement are unaffected. DBA transactions, queries, or PL/SQL
statements are also unaffected.
 QUIESCED - ALTER SYSTEM QUIESCE RESTRICTED has been issued: no user transactions, queries, or
PL/SQL statements are processed. DBA transactions, queries, or PL/SQL statements are unaffected. User
transactions, queries, or PL/ SQL statements issued after the ALTER SYSTEM QUIESCE RESTRICTEDstatement
are not processed.

A single ALTER SYSTEM QUIESCE RESTRICTED statement quiesces all instances in an Oracle RAC environment.
After this statement has been issued, some instances may enter into a quiesced state before other instances; the system is
quiesced when all instances enter the quiesced state.

BLOCKED VARCHAR2(3) Indicates whether all services are blocked (YES) or not (NO)
9. Retrouver le nom de la base et son mode d’ouverture (v$database).
select name, open_mode from v$database;
10. A l’aide de la vue v$parameters$, les fichiers de contrôle de la base.

11. Identifier les fichiers de redo log à l’aide de la vue v$logfile.

V$LOGFILE contains information about redo log files. (select group# from v$logfile;)

Column Datatype Description


GROUP# NUMBER Redo log group identifier number
STATUS VARCHAR2(7) Status of the log member:
 INVALID - File is inaccessible
 STALE - File's contents are incomplete
 DELETED - File is no longer used
 null - File is in use

TYPE VARCHAR2(7) Type of the logfile:


 ONLINE
 STANDBY

MEMBER VARCHAR2(513) Redo log member name


IS_RECOVERY_DEST_FILE VARCHAR2(3) Indicates whether the file was created in the flash recovery area (YES) or not (NO)

12. Identifier les fichiers de données et leur taille à l’aide de la vue v$datafile.
select blocks from v$datafile;
Column Datatype Description

FILE# NUMBER File identification number

CREATION_CHANGE# NUMBER Change number at which the datafile was created

CREATION_TIME DATE Timestamp of the datafile creation

TS# NUMBER Tablespace number

RFILE# NUMBER Tablespace relative datafile number

STATUS VARCHAR2(7) Type of file (system or user) and its status. Values: OFFLINE, ONLINE, SYSTEM, RECOVER,SYSOFF (an
offline file from the SYSTEMtablespace)

ENABLED VARCHAR2(10) Describes how accessible the file is from SQL:


 DISABLED - No SQL access allowed
 READ ONLY - No SQL updates allowed
 READ WRITE - Full access allowed
 UNKNOWN - should not occur unless the control file is corrupted

CHECKPOINT_CHANGE# NUMBER SCN at last checkpoint

CHECKPOINT_TIME DATE Timestamp of the checkpoint#

UNRECOVERABLE_CHANGE# NUMBER Last unrecoverable change number made to this datafile. If the database is in ARCHIVELOGmode, then
this column is updated when an unrecoverable operation completes. If the database is not
in ARCHIVELOG mode, this column does not get updated.

UNRECOVERABLE_TIME DATE Timestamp of the last unrecoverable change. This column is updated only if the database is
in ARCHIVELOG mode.
Column Datatype Description

LAST_CHANGE# NUMBER Last change number made to this datafile (null if the datafile is being changed)

LAST_TIME DATE Timestamp of the last change

OFFLINE_CHANGE# NUMBER Offline change number of the last offline range. This column is updated only when the datafile is
brought online.

ONLINE_CHANGE# NUMBER Online change number of the last offline range

ONLINE_TIME DATE Online timestamp of the last offline range

BYTES NUMBER Current datafile size (in bytes); 0 if inaccessible

BLOCKS NUMBER Current datafile size (in blocks); 0 if inaccessible

CREATE_BYTES NUMBER Size when created (in bytes)

BLOCK_SIZE NUMBER Block size of the datafile

NAME VARCHAR2(513) Name of the datafile

PLUGGED_IN NUMBER Describes whether the tablespace is plugged in. The value is 1 if the tablespace is plugged in and has
not been made read/write, 0 if not.

BLOCK1_OFFSET NUMBER Offset from the beginning of the file to where the Oracle generic information begins. The exact length of
the file can be computed as follows: BYTES + BLOCK1_OFFSET.

AUX_NAME VARCHAR2(513) Auxiliary name that has been set for this file via CONFIGURE AUXNAME
Column Datatype Description

FIRST_NONLOGGED_SCN NUMBER First nonlogged SCN

FIRST_NONLOGGED_TIME DATE First nonlogged time

13. Quels sont les noms et les numéros des tablespace ? (v$tablespace)
select TS#,name from v$tablespace;

This view displays tablespace information from the control file.

Column Datatype Description


TS# NUMBER Tablespace number
NAME VARCHAR2(30) Tablespace name
INCLUDED_IN_DATABASE_BACKUP VARCHAR2(3) Indicates whether the tablespace is included in full database backups using the BACKUP
DATABASE RMAN command (YES) or not (NO).NO only if the CONFIGURE EXCLUDE RMAN
command was used for this tablespace.
BIGFILE VARCHAR2(3) Indicates whether the tablespace is a bigfile tablespace (YES) or not (NO)
FLASHBACK_ON VARCHAR2(3) Indicates whether the tablespace participates in FLASHBACK DATABASE operations (YES) or not
(NO)
ENCRYPT_IN_BACKUP VARCHAR2(3) Possible values are:

 ON - encryption is turned ON at tablespace level


 OFF - encryption is turned OFF at tablespace level
Column Datatype Description
 NULL - encryption is neither explicitly turned on or off at tablespace level (default or when
CLEARED).

Vous aimerez peut-être aussi