# Database \> Export \> Generate Database Script (Sorting)

**URL:** <https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416>\
**Category:** Toad for Oracle & DevOps Toolkit\
**Created:** [November 4, 2022, 9:59am UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416 "2022-11-04T09:59:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpoenn](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jpoenn](https://forums.toadworld.com/u/jpoenn)\
**Post date:** [November 4, 2022, 9:59am UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416/1 "2022-11-04T09:59:27Z")

</div>

Hi all,

i try to export DB Script (Toad 16.2) to move to a new instance with the simiar schema/roles/...

But i already fail with exporting roles in the correct sorting.

Short Sample Export (no matter if i use Option Script \> Sort for Creation):

CREATE ROLE ACCOUNTMANAGEMENT NOT IDENTIFIED;

-- System privileges granted to ACCOUNTMANAGEMENT  
GRANT ALTER USER TO ACCOUNTMANAGEMENT;  
GRANT CREATE USER TO ACCOUNTMANAGEMENT;  
GRANT DROP USER TO ACCOUNTMANAGEMENT;

-- Roles granted to ACCOUNTMANAGEMENT  
GRANT SELECT\_BATCHES TO ACCOUNTMANAGEMENT WITH ADMIN OPTION;  
GRANT SELECT\_MATERIAL TO ACCOUNTMANAGEMENT WITH ADMIN OPTION;

later in the script........

CREATE ROLE SELECT\_BATCHES NOT IDENTIFIED;  
CREATE ROLE SELECT\_MATERIAL NOT IDENTIFIED;

What do i have to do to get an usable Script that runs once and without any errors?

Yes, i can only export roles to get just the create roles, but how to get only the Object and System grants without a create role statement?

Thank you for your support

BR  
J

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [November 4, 2022, 12:54pm UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416/2 "2022-11-04T12:54:57Z")

</div>

It looks like role dependency sorting doesn't happen unless this box is checked. That's a bug and I'll fix it. Do you have it checked?

 ![image](https://global.discourse-cdn.com/quest/original/2X/c/c4eef52eb77279a78f61a8e8c98861690e0bb63a.png)

I guess as a workaround, you could create a script with only "Roles" checked.  
 ![image](https://global.discourse-cdn.com/quest/original/2X/2/26e6e55159f9d0a2e9708658a5186b0beaf9c557.png)

Run that script first, then run the script with everything you need checked, and ignore errors.

Then you could do a DB Compare to make sure everything is ok, since you ignored errors and might not be sure.

Sorry about that. I'll fix.

---

<div class="post-metadata">

**Author:** ![jpoenn](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jpoenn](https://forums.toadworld.com/u/jpoenn)\
**Post date:** [November 7, 2022, 5:07am UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416/3 "2022-11-07T05:07:14Z")

</div>

Thanks John.

In all my attempts it made no difference whether the checkbox was activated or not.  
So it looks like a bug yes.

![image](https://global.discourse-cdn.com/quest/original/2X/c/c88b8610148d681057649fbc2ebfcaf27f323a60.png)

Do you have an idea when it is fixed?

THX

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [November 7, 2022, 3:55pm UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416/4 "2022-11-07T15:55:54Z")

</div>

It should work if you check both "sort for creation" and "object privileges granted to roles".

It will be fixed in the next beta.

---

<div class="post-metadata">

**Author:** ![jpoenn](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jpoenn](https://forums.toadworld.com/u/jpoenn)\
**Post date:** [November 7, 2022, 4:45pm UTC](https://forums.toadworld.com/t/database-export-generate-database-script-sorting/56416/5 "2022-11-07T16:45:25Z")

</div>

FIXED in **Beta 16.3.29.1831, Released 7-Nov-2022**

Thank you John
