# Creating Indexes via Macro

**URL:** <https://forums.toadworld.com/t/creating-indexes-via-macro/2359>\
**Category:** Toad Data Modeler\
**Created:** [October 4, 2010, 10:30am UTC](https://forums.toadworld.com/t/creating-indexes-via-macro/2359 "2010-10-04T10:30:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobF](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@RobF](https://forums.toadworld.com/u/RobF)\
**Post date:** [October 4, 2010, 10:30am UTC](https://forums.toadworld.com/t/creating-indexes-via-macro/2359/1 "2010-10-04T10:30:40Z")

</div>

Is there a way to create indexes (or attributes, etc.) using a macro? I want to create indexes for every FK in each table and have them named properly. I have gotten several rename macros to work well but not sure how to go about creating new things in the model. Thanks.

---

<div class="post-metadata">

**Author:** ![Vaclav\_Frolik](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/vaclav_frolik/32/12_2.png) [@Vaclav\_Frolik](https://forums.toadworld.com/u/Vaclav_Frolik)\
**Post date:** [October 6, 2010, 2:54pm UTC](https://forums.toadworld.com/t/creating-indexes-via-macro/2359/2 "2010-10-06T14:54:40Z")

</div>

Hi,

at the following page you can find a script that creates index for autoincrement attributes:  
[http://modeling.inside.quest.com/entry.jspa?externalID=2245&categoryID=35](http://modeling.inside.quest.com/entry.jspa?externalID=2245&categoryID=35)

You can use it for inspiration.

Extract from the script where you can see how to create new index via script:  
…  
Index = Entity.CreateNewObject( 2012 );  
//Create new Index (2012 is object type of PERIndex)  
Index.Name = IndexName;  
IndexItem = Index.CreateNewObject( 2013 );  
//Create new Item of Index (2013 is object type of PERIndexItem)  
IndexItem.Attribute = Attribute;  
…

Feel free to write me back in case you need my help with modifications.

Regards,

Vaclav
