In sqlserver, it is impossible that if we want to create an function index. Doesn`t means we can not ?
Father said there always a way. That is virtual column.

Here is an exmple:

Sample 1
create table #checkdistribute ([CELL_ID] [varchar](20) NOT NULL)
create table #checkdistribute1 ([CELL_ID1] [varchar](2) NOT NULL)

INSERT #checkdistribute (CELL_ID) select CELL_ID from T with(nolock)
create NONCLUSTERED INDEX IDX_checkdistribute_cellid on #checkdistribute (CELL_ID asc)
INSERT #checkdistribute1 (CELL_ID1) select SUBSTRING(CELL_ID,1,2) from #checkdistribute

Although we generated an index but it still can not be use,. Because , Yes, SUBSTRING

Yes, Tables Scan.

Just wait. we also have a hope.

Sample 2

create table #checkdistribute ([CELL_ID] [varchar](20) NOT NULL,[CELL_ID_F] AS SUBSTRING(CELL_ID,1,2) )
create table #checkdistribute1 ([CELL_ID1] [varchar](2) NOT NULL)

INSERT #checkdistribute (CELL_ID) select CELL_ID from T with(nolock)
create NONCLUSTERED INDEX IDX_checkdistribute_cellid on #checkdistribute ([CELL_ID_F] asc)
INSERT #checkdistribute1 (CELL_ID1) select CELL_ID_F from #checkdistribute

It works

virtual column make sqlserver using function index的更多相关文章

  1. [oracle 11g 新特性] virtual column虚拟列

    总结:虚拟列可以使用于一些特殊场合,实质是类似于函数列(即以 表中已有的列 经过函数运算得来),“虚拟列不存储在数据库中,是在执行查询时由oracle后台计算出来返回给用户”,因此虚拟列不会增加存储空 ...

  2. Oracle 11g 虚拟列 Virtual Column介绍

    Oracle 11G 虚拟列 Virtual Column Oracle 11G 在表中引入了虚拟列,虚拟列是一个表达式,在运行时计算,不存储在数据库中,不能更新虚拟列的值. 定义一个虚拟列的语法: ...

  3. 【转】Oracle virtual column(虚拟列)

    为什么要使用虚拟列 (1)可以为虚拟列创建索引(Oracle为其创建function index) (2)可以搜集虚拟列的统计信息statistics,为CBO提供一定的采样分析. (3)可以在whe ...

  4. ajax 中$.each(json,function(index,item){ }); 中的2个参数表示什么意思?

    $.each(json,function(index,item)里面的index代表当前循环到第几个索引,item表示遍历后的当前对象,比如json数据为:[{"name":&qu ...

  5. jquery的$(selector).each(function(index,element))和$.each(dataresource,function(index,element))的区别

    $(selector).each(function(index,element)) 定义和用法 each() 方法规定为每个匹配元素规定运行的函数. $(selector).each(function ...

  6. $.each(obj,function(index,value)遍历的学习

    JQuery遍历对象 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  7. ORA-01733: virtual column not allowed here

    基表: hr.tt  scott.tt  视图1: 基于 hr.tt  union all  scott.tt ---> scott.ttt  视图2: 基于 视图1->scott.ttt ...

  8. $.each(data, function (index, value) { })的用法;json和list<>的互相转换

    在json中常常碰到这样的代码: jquery $.each(data, function (index, value) {    }) 遍历处理data,可以是数组.DOM.json等,取决于直接给 ...

  9. SQLServer:FUNCTION/CURSOR/PROCEDURE/TRIGGER

    一.FUNCTION:在sqlserver2008中有3中自定义函数:标量函数/内联表值函数/多语句表值函数,首先总结下他们语法的异同点:同点:1.创建定义是一样的:                  ...

随机推荐

  1. 【转载】巴塞尔问题(Basel Problem)的多种解法

    如何计算 \(\displaystyle \zeta \left ( 2 \right )=\frac{1}{1^{2}}+\frac{1}{2^{2}}+\frac{1}{3^{2}}+\cdots ...

  2. 公用技术——面向对象领域——UML图——《The Unified Modeling Language User Guide》V2读书笔记——第一章节(建模的意义)

    第一章节到第三章节介绍UML的基本概念.第一章节主要介绍了UML语言的历史,介绍了建模的重要性(狗窝,房子,大厦),介绍了UML要实现哪些目标,在最后介绍了在使用UML语言时应该遵循的一些原则或者是规 ...

  3. 关于this和base的区别

    一句话总结:在有冲突得时候,base和this能够进行区分,在没有冲突得时候,是一样得. 基于成员调用 基于构造方法 参考: http://www.cnblogs.com/reommmm/archiv ...

  4. hamming distance(汉明距离)

    看knn算法时无意间发现这个算法,但是维基上有错误的示例和python代码...因为汉明距离并不是求相同长度字符串(或相同长度的整数)之间的字符(或数位)差异个数. 正确的详见:https://en. ...

  5. 转载--php 7.2 安装 mcrypt 扩展

    在 php 官网下载 mcrypt 包,php 扩展官网 # wget http://pecl.php.net/get/mcrypt-1.0.1.tgz # tar xf mcrypt-1.0.1.t ...

  6. 操作系统OS - 阻塞(Blocking)非阻塞(Non-Blocking)与同步(Synchronous)异步(Asynchronous)

    参考: http://blog.jobbole.com/103290/ https://www.zhihu.com/question/19732473/answer/23434554 http://b ...

  7. photoshop下载(ps)

    https://pan.baidu.com/s/1bNrUod2n1VqsA7Fr9RHtsg

  8. 18 JavaScript字符串方法

    indexOf():从头到尾进行检索.返回指定文本在字符串最后一次出现的索引,否则返回-1.可以指定第二个参数作为起始位置. lastIndexOf:从尾到头进行检索.返回指定文本最后出现的位置,否则 ...

  9. RADIUS Authentication with WPA2-Enterprise

    概观具有802.1X身份验证的WPA2-Enterprise可用于对域中的用户或计算机进行身份验证.请求方supplicant(无线客户端)使用RADIUS服务器上配置的EAP方法对RADIUS服务器 ...

  10. Nexus 3048的NX-OS升级方法

    1.System Software和Kick Start 与普通IOS设备不同,NX OS升级时,共有2个文件需要升级.安装,如果只安装其中一个,可能会导致设备重启后无法进入系统.这2个文件包括: N ...