How to create a user with a particular user_id?
-
16-10-2019 - |
Question
Is it possible to specify the user_id of a user while creating it?
SQL> create user user1 identified by user1;
User created.
SQL> select user_id, username from all_users where username='USER1';
USER_ID USERNAME
---------- ------------------------------
72 USER1
SQL>
Instead of 72, can it be a number that I specify?
Solution
Not in a supported fashion, no.
Why would you care what the USER_ID
of a new user was? That would seem to raise a pile of red flags in my mind.
OTHER TIPS
If you want to migrate logins and users from a server to another there should be another way then forcing their ids and names.
In SQL Server for example there is a system stored procedure (sp_help_revlogin) that generates the necessary scripts to migrate users between servers. I don't know for Oracle, but I'm sure someone has met the problem before.
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange