Pergunta

I have a migration that will create an index in a table of our Oracle database. The DBA would like the index to be created ONLINE. (Something like CREATE INDEX ..... ONLINE;) Is there something I can add to the tag below to accomplish what I want or do I need to write the SQL into the migration?

<createIndex tableName="USER" indexName="IX_USER_TX_ID">
     <column name="TX_ID" />
</createIndex>
Foi útil?

Solução

There is no standard tag to specify it as ONLINE. Your 3 options to create it as ONLINE are:

  1. Fall back to the tag where you specify the exact SQL you want
  2. Use the modifySql tag to append to the generated SQL.
  3. Create an extension to createIndex that always generates ONLINE at the end of the SQL or adds a parameter to createIndex that allows you to control if it is added or not.

Option #2 is probably the best mix of easy yet flexible and would look something like this:

<changeSet id="1" author="nvoxland">
    <createIndex tableName="USER" indexName="IX_USER_TX_ID">
        <column name="TX_ID" />
    </createIndex>
    <modifySql dbms="oracle">
         <append value=" ONLINE"/>
    </modifySql>
</changeSet>

Notice the space in the value tag. Append does a very simple text append with no built-in logic.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top