简体   繁体   中英

How do I create a user that can create users in Oracle 12c?

I have created a user, granted all the privileges you can see in SQL Developer except sysdba and logged in as the new user, but I still cannot create other users.

Here is what I have done so far:

  1. Login as local sysdba;

  2. Run:

     CREATE USER USERA IDENTIFIED BY "PWDpwd123" DEFAULT TABLESPACE TBS1 TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; 
  3. Grant all privileges and roles you can see in SQL Developer to USERA;

  4. Login as USERA;

  5. Run:

      CREATE USER USERB IDENTIFIED BY "pwd321" DEFAULT TABLESPACE TBS2 TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; 

And then I get a ORA-01031 ERROR . What's wrong? Many thanks for your help!

You need to grant CREATE USER system priviege to that user.

GRANT CREATE USER to username;

You can also grant ALTER USER and DROP USER system privileges to this user.

See the documentation: https://docs.oracle.com/database/121/SQLRF/statements_9013.htm#i2077938

System Privilege Name: CREATE USER

Create users. This privilege also allows the creator to:

Assign quotas on any tablespace. Set default and temporary tablespaces. Assign a profile as part of a CREATE USER statement.


EDIT - practical example


C:\>sqlplus system as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jan 16 15:16:52 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> create user test123 identified by test;

User created.

SQL> grant connect to test123;

Grant succeeded.

SQL> grant create user to test123;

Grant succeeded.

SQL> connect test123
Enter password:
Connected.
SQL> create user alamakota1 identified by alamakota;

User created.

SQL> select user from dual;

USER
------------------------------
TEST123

SQL>

The last command SELECT user FROM dual shows, that the current (logged) user is user123

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM