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. 去除移动端苹果手机(ios)的input默认样式与input禁止键盘出现的方式

    样式: input{-webkit-appearance: none;} 在iPhone plus点击input框出生日期时会出现如下图: 为了去掉下面那条苹果自带的,可以这样处理:在HTML中的in ...

  2. acm数论之旅--中国剩余定理

    ACM数论之旅9---中国剩余定理(CRT)(壮哉我大中华╰(*°▽°*)╯)   中国剩余定理,又名孙子定理o(*≧▽≦)ツ 能求解什么问题呢? 问题: 一堆物品 3个3个分剩2个 5个5个分剩3个 ...

  3. Linux动态库路径配置

    参考链接:https://blog.csdn.net/blade2001/article/details/32839937 为什么要关注动态库路径配置,是因为工作中遇到动态库依赖其他动态库,而其他动态 ...

  4. SpringBoot-自动装载

    1,SpringBoot里面有内置的tomcat容器. 2,SpringBoot是基于已有的东西创建的新的东西.核心:(AutoConfiguration)自动装载,Starter,Actuator, ...

  5. Go标准库之Log

      文章引用自 Go语言标准库log介绍 无论是软件开发的调试阶段还是软件上线之后的运行阶段,日志一直都是非常重要的一个环节,我们也应该养成在程序中记录日志的好习惯. log Go语言内置的log包实 ...

  6. 行内元素的上下margin 和 img元素的上下margin

    行内元素的特点有: 1.与其他元素在同一行 2.宽度(width).高度(height).内边距的top/bottom(padding-top/padding-bottom)和外边距的top/bott ...

  7. 记录我对'我们有成熟的时间复杂度为O(n)的算法得到数组中任意第k大的数'的误解

    这篇博客记录我对剑指offer第2版"面试题39:数组中出现次数超过一半的数字"题解1的一句话的一个小误解,以及汇总一下涉及partition算法的相关题目. 在剑指offer第2 ...

  8. 获取input type=radio属性的value值

    个人代码1: <div class="form-group" style="width: 250px;margin:0 auto;"> <la ...

  9. 再次立个flag

    今天2019.9.18 从上次迷茫到现在,差不多过去快一年了.   准确点是 442 天 我顺便大概看了一下上次迷茫时期的日志,总觉的不可思议.上次是毕业大概几个月,到目前其实也没多久,但是我变了.. ...

  10. AngularJS学习:第一个demo

    1. 引入angular.js 相应版本下载地址: https://code.angularjs.org/ 2. 编写html <!DOCTYPE html> <html> & ...