Function-based indexes in SQL Server

后端 未结 1 1253
北海茫月
北海茫月 2020-12-01 23:42

I\'m trying to understand if function based indexes similar to the one\'s in Oracle or PostgreSQL exist in SQL Server

In PostgreSQL, I can create a function based in

相关标签:
1条回答
  • 2020-12-02 00:13

    I researched a bit further based on Damien's comment and found an answer that comes very close to matching Oracle's/PostgreSQL's function based indexes.

    I have a table named PARCELS where I created a new column COMPUTEDPARCELS by using the alter statement as given below:

    ALTER TABLE [PARCELS] ADD COMPUTEDPARCELS AS CONVERT(CHAR(8), [MAPNO], 112);
    

    And then create an index on the computed column:

    CREATE INDEX function_index ON [PARCELS](COMPUTEDPARCELS);
    

    Of course the example is pretty simple but behaves just like a function based index.

    0 讨论(0)
提交回复
热议问题