jeudi 18 septembre 2014

Comment créer des utilisateurs communs (common users) sans le préfixe C##

Avec Oracle database 12c, lorsqu'on veut créer un utilisateur commun (common user) avec un nom ordinaire (un nom tel qu'on utilisait dans les versions antérieures), on reçoit le message d'erreur suivant:

ERREUR à la ligne 1 :
ORA-65096: nom utilisateur ou de role commun non valide


Exemple:

C:\Users\Herve Hetche>sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Jeu. Sept. 11 14:27:20 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ConnectÚ Ó :
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SYS@oracdb> show con_name
CON_NAME
------------------------------
CDB$ROOT

SYS@oracdb> create user hetche identified by hetche;
create user hetche identified by hetche
            *
ERREUR à la ligne 1 :
ORA-65096: nom utilisateur ou de role commun non valide


SYS@oracdb>

Cela est causé par le paramètre caché "_common_user_prefix".

SYS@oracdb> select value from v$parameter
  2  where name='_common_user_prefix';

VALUE
--------------------------------------------------------------------------------
C##

SYS@oracdb>

OU

SYS@oracdb> select a.ksppinm "Parameter",
b.ksppstvl "Session Value",
c.ksppstvl "Instance Value", a.ksppdesc "Description"
from x$ksppi a,
x$ksppcv b,
x$ksppsv c
where a.indx = b.indx and a.indx = c.indx
and substr(ksppinm,1,1)=’_’ and lower(a.ksppinm) like ‘%common_user_prefix%’;

Parameter
--------------------------------------------------------------------------------
Session Value
--------------------------------------------------------------------------------
Instance Value
--------------------------------------------------------------------------------
Description
--------------------------------------------------------------------------------
_common_user_prefix
C##
C##

Enforce restriction on a prefix of a Common User/Role/Profile name

SYS@oracdb>

Modifier le paramètre comme suit:

SYS@oracdb> alter system set "_common_user_prefix"='' scope=both;
alter system set "_common_user_prefix"='' scope=both
                 *
ERREUR à la ligne 1 :
ORA-02095: Le paramètre d'initialisation indiqué ne peut pas être modifié


SYS@oracdb> alter system set "_common_user_prefix"='' scope=spfile;
Système modifié.
SYS@oracdb>

Et redémarrer la BD:

SYS@oracdb> shutdown immediate
Base de donnÚes fermÚe.
Base de donnÚes dÚmontÚe.
Instance ORACLE arrÛtÚe.
SYS@oracdb> startup
Instance ORACLE lancÚe.

Total System Global Area  730714112 bytes
Fixed Size                  2443824 bytes
Variable Size             545261008 bytes
Database Buffers          176160768 bytes
Redo Buffers                6848512 bytes
Base de donnÚes montÚe.
Base de donnÚes ouverte.
SYS@oracdb>

Vérifier la valeur du paramètre (on vient bien qu'elle est nulle):

SYS@oracdb> select value from v$parameter
  2  where name='_common_user_prefix';

VALUE
--------------------------------------------------------------------------------


SYS@oracdb> select a.ksppinm "Parameter",
  2  b.ksppstvl "Session Value",
  3  c.ksppstvl "Instance Value", a.ksppdesc "Description"
  4  from x$ksppi a,
  5  x$ksppcv b,
  6  x$ksppsv c
  7  where a.indx = b.indx and a.indx = c.indx
  8  and substr(ksppinm,1,1)='_' and lower(a.ksppinm) like '%common_user_prefix%';

Parameter
--------------------------------------------------------------------------------
Session Value
--------------------------------------------------------------------------------
Instance Value
--------------------------------------------------------------------------------
Description
--------------------------------------------------------------------------------
_common_user_prefix
Enforce restriction on a prefix of a Common User/Role/Profile name


Reprendre la création de l'utilisateur:

SYS@oracdb> create user hetche identified by hetche;
Utilisateur créé.
SYS@oracdb> grant dba to hetche;
Autorisation de privilèges (GRANT) acceptée.
SYS@oracdb> column username format a20
SYS@oracdb> select username, common from dba_users where username='HETCHE';


USERNAME              COM
---------------------             ---
HETCHE                   YES

SYS@oracdb>

Si vous voulez remettre la valeur par défaut, à vous de décider !

Hope it helps....

Aucun commentaire:

Enregistrer un commentaire