Question

The company I'm working at is migrating their databases from Oracle 10g to 11g. On Monday we want to clean our development database and clone the production database to that storage.

Here we go again. My second task is a little bit more complicated I think. On the development database we have got ~200 users and on the production database something like 1500 users. Now I shall write a script that should return all users from our development database and export them. After that another script should search all the users of the production database without any objects and delete them, but non of the system schema or user schema, and import the old users of the development database. Is there a way to do all those things in a script or query?

Best regards,

Chris (IT student, but total database newbie)

Was it helpful?

Solution

To migrate your users from dev to production you should use data pump import/export. You can use this to specify which users to export/import. This will also bring their objects, privileges, etc. so you can be sure you have everything.

To remove users that have no objects, run the following to generate a script:

SELECT 'drop user ' || username || ';' 
FROM   dba_users u
where  not exists (select null 
                   from   dba_objects o 
                   where  o.owner = u.username);

You can then review the output of this, checking it's only removing the users you expect and run that script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top