Quantcast
Mardi 7 juin 2011 2 07 /06 /Juin /2011 00:08

 

Script Lister les Constraints d'une Table.

Comment voir et lister les contraintes d'une Table ou View Oracle ?

Lister les Contraintes.

Les valeurs de CONSTRAINT_TYPE :

  • P (Primary key).
  • U (Unique key).
  • R (Referential integrity).
  • C (Check constraint).
  • V (with check option on a view).
  • O (with read only on a view).
 

REPHEADER PAGE CENTER 'LISTE DES CONTRAINTES D''UNE TABLE OU VIEW'
SET LINESIZE 100
SET PAGESIZE 900
COL CONSTRAINT_NAME FORMAT A20
COL INDEX_NAME FORMAT A20
COL COLUMN_NAME FORMAT A15
SELECT   a.constraint_name,
         DECODE(a.constraint_type,'C', 'Check constraint',
                                  'P', 'Primary Key',
                                  'U', 'Unique Key',
                                  'R', 'Referential Integrity',
                                  'V', 'With Check Option on a View',
                                  'O', 'With Read Only on a View',
                                  'Autre à définir') CONSTRAINT_TYPE,
         a.index_name,
         b.column_name,
         b.position
  FROM   all_constraints a INNER JOIN all_cons_columns b
                           ON (a.constraint_name = b.constraint_name
                               AND a.owner = b.owner)
 WHERE   a.table_name = 'UTILISATEUR'
   AND   a.owner = 'ORA'
 ORDER BY 3,2;

 

Aperçu Script Lister Constraints.

 


                              LISTE DES CONTRAINTES D'UNE TABLE OU VIEW

CONSTRAINT_NAME      CONSTRAINT_TYPE             INDEX_NAME           COLUMN_NAME       POSITION
-------------------- --------------------------- -------------------- --------------- ----------
PK_UTICODE           Primary Key                 PK_UTICODE           UTI_CODE                 1
UNQ_UTI_U            Unique Key                  UNQ_UTI_U            UTI_USER                 1
CHK_ADMIN            Check constraint                                 UTI_ADM
SYS_C0015629         Check constraint                                 UTI_NOM
SYS_C0015630         Check constraint                                 UTI_PRENOM
SYS_C0015627         Check constraint                                 UTI_USER
SYS_C0015628         Check constraint                                 UTI_PASSE
FK_UTI_SITE          Referential Integrity                            SITE_CODE                 1

8 ligne(s) sélectionnée(s).

Haut de Page www.dba-ora.fr

 

 

Liens en rapport avec l'article et qui sont susceptibles de vous intéresser
 
Par Daniel Roesch - Publié dans : TABLES
Ecrire un commentaire - Voir les 0 commentaires
Retour à l'accueil

Oracle Sql et administration

Contact - C.G.U. - Rémunération en droits d'auteur - Signaler un abus - Articles les plus commentés