# Generate Schema Script

**URL:** <https://forums.toadworld.com/t/generate-schema-script/58282>\
**Category:** Toad for Oracle - Beta\
**Created:** [October 7, 2023, 12:15am UTC](https://forums.toadworld.com/t/generate-schema-script/58282 "2023-10-07T00:15:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfalco](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dfalco](https://forums.toadworld.com/u/dfalco)\
**Post date:** [October 7, 2023, 12:15am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/1 "2023-10-07T00:15:34Z")

</div>

Hi John,

I have started testing the updates in this version you have added for me and have some comments to pass back your way. At this time, I have been generating the following objects: Functions, Packages, Procedures, Sequences, Tables, Triggers, Types and Views.

Probably the only major issue I have so far with the generation of scripts is the completed scripts do not have grants AND synonyms. If an object only has grants or only has synonyms, these are generated correctly. But if an object has both grants and synonyms, it appears to only generate the grants NOT the synonyms.

The other less important observations are:

- every run has produced an empty 'JavaSources' directory
- when combining specs/body into one script, empty 'PackageBodies' and 'TypeBodies' directories are created
- when choosing to put indexes/constraints into the object script, empty indexes and constraint directories are also created

The empty directory creation is only cosmetic and easily dealt with.

I have not completed testing, but I thought I would send you what I have so far.

Thanks for your amazing work John.

Regards,

David.

---

<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:** [October 9, 2023, 12:10pm UTC](https://forums.toadworld.com/t/generate-schema-script/58282/2 "2023-10-09T12:10:46Z")

</div>

Hi Dave,

Thanks for the follow up.

I'll look at these bugs today - especially the grants/synonyms one.

-John

---

<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:** [October 9, 2023, 2:33pm UTC](https://forums.toadworld.com/t/generate-schema-script/58282/3 "2023-10-09T14:33:25Z")

</div>

Hi Dave,

Here's what I'm seeing regarding grants and synonyms:

1. No problems with grants
2. Public synonyms are always created
3. Private synonyms: Generate Schema Script only creates private synonym scripts for synonyms owned by the schema being exported. This is by design. So if you have private synonyms owned by other schemas, which refer to objects owned by the schema being exported - well, you'd have to export a schema script for the synonym owner to get create scripts for those synonyms. I hope that makes sense and is not a problem.

The empty "JavaSource" folder is fixed in the beta that was released this morning, and I'll make a change to 17.0 to fix the other empty directories. The folders will briefly appear as the schema script is being created, but then the empty ones will be deleted at the end or the process.

**Edit** : I was just looking at the code for extracting synonyms. I forgot we already had this option to extract private synonyms owned by other schemas in Compare Schemas, so adding this to Generate Schema Script is trivial. I'll add it to 17.0.

-John

---

<div class="post-metadata">

**Author:** ![dfalco](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dfalco](https://forums.toadworld.com/u/dfalco)\
**Post date:** [October 18, 2023, 2:26am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/4 "2023-10-18T02:26:29Z")

</div>

Hi John,

Adding to interesting observations, I have found an issue that exists also in version 16.3.231.2085.

It appears. that if I try to generate a SPEC and BODY script combined, the completed script is not always completed but rather truncated towards the end of the 'BODY'.

This appears on generated files that are either over 125k in size or greater than 3000 lines.

The method I use in version 16.3.231.2085:  
1 - login to database as required schema owner  
2 - select object type - packages (lines must excess 3000)  
3 - select required packages on the left  
4 - select create script  
5 - ensure one file per object  
6 - ensure script options include keep spec and body in same file  
7 - generate scripts

So note this is also happening under the new 'Generate Schema Scripts' functionality.

I have not found any 'formatting' limitations under options other than:  
options -\> Scripts -\> Script Output -\> Limit results to -- lines, this is set to 0

Cheers,  
Dave.

---

<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:** [October 18, 2023, 11:55am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/5 "2023-10-18T11:55:01Z")

</div>

HI Dave,

I am not aware of this bug but will investigate today and get back to you

-John

---

<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:** [October 18, 2023, 2:45pm UTC](https://forums.toadworld.com/t/generate-schema-script/58282/6 "2023-10-18T14:45:11Z")

</div>

I tried to reproduce this by adding about 25,000 lines worth of comments in both a package spec and body. I then turned on the "combine" option and the entire code base was there no problem.

I do have an idea though.

Is it possible that you have a CHR(0) character somewhere in your source? That character tells windows programs "this is the end of the text", so it causes text to get cut off.

The easiest way to look for it is using this SQL.

```auto
select *
from dba_source
where instr(text, CHR(0)) > 0

```

---

<div class="post-metadata">

**Author:** ![dfalco](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dfalco](https://forums.toadworld.com/u/dfalco)\
**Post date:** [October 19, 2023, 12:36pm UTC](https://forums.toadworld.com/t/generate-schema-script/58282/7 "2023-10-19T12:36:35Z")

</div>

Hi John,

Thanks for your help. On further investigation, I've determined that the issue was on my end and not with Toad.

I was viewing these generated scripts through the Windows preview pane in explorer which does have a limit to the number of lines it can display. When viewed by text editors such as Notepad++, all lines are present and accounted for.

I can only apologize for the inconvenience I caused you and the time you spent investigating this issue I reported,

I wanted to ensure this was clarified to prevent any further unnecessary troubleshooting efforts on your part.

Again, my apologies.

Dave

---

<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:** [October 19, 2023, 12:40pm UTC](https://forums.toadworld.com/t/generate-schema-script/58282/8 "2023-10-19T12:40:05Z")

</div>

Hi Dave,

It's fine. It only took me about 5 minutes. You have nothing to apologize for. The actual bugs you found more than made up for it. I appreciate you testing this stuff and letting me know what you find.

-John

---

<div class="post-metadata">

**Author:** ![dfalco](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dfalco](https://forums.toadworld.com/u/dfalco)\
**Post date:** [May 22, 2024, 2:13am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/9 "2024-05-22T02:13:57Z")

</div>

Hi John,

I am using the latest Toad 17.1 and running the Generate Schema Script and all is working well except for one thing I can't seem to get around.

Many of the scripts are being generated with a heading, as an example...

```auto
 --
 -- CHECK_METER_EXCEPTIONS (Function) 
 --

```

and if I have synonyms included within the main script, they too have headings, ie...

```auto
 --
 -- GET_IPARM_ITEM (Synonym) 
 --

```

With Packages where the package and body are in the one script, I get a heading for both.

What I really want is to remove the headings (but keep script comments). I have looked in all places to try to get the scripts generated without these comments but I can't find anywhere to do this.

note that toad options -\> Formatter -\> Header is disabled. So too are all formatting options in options directly under the 'schema generate script' procedure.

Am I missing something?

Dave.

---

<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:** [May 22, 2024, 2:19am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/10 "2024-05-22T02:19:38Z")

</div>

Hi Dave,

You can prevent the header comments by unchecking this option:

 ![image](https://global.discourse-cdn.com/quest/original/3X/5/5/555cc8c8b12b225507d04a4577fe41be0d6dfd7e.png)

Maybe it should have different wording. I can see how it doesn't really convey "object name as a comment before object's create statement".

-John

---

<div class="post-metadata">

**Author:** ![dfalco](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@dfalco](https://forums.toadworld.com/u/dfalco)\
**Post date:** [May 22, 2024, 5:30am UTC](https://forums.toadworld.com/t/generate-schema-script/58282/11 "2024-05-22T05:30:00Z")

</div>

Excellent John, I knew I was missing something. It was a case of I'd been looking at the screen for far too long.

Thank you, not only for your help, but the speed of your reply.  
Very much appreciated.

Dave
