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. reStructuredText语法

    reStructuredText 除了makedown语法这还存在另一种语法reStructuredText 相对Markdown来说,在写书方面更有优势: 使用sphnix能够自动生成目录和索引文件 ...

  2. 第一篇 Python中一切皆对象

  3. 安卓基础(Navigation)

    今天学习了简单的Navigation:页面导航. 页面导航的简单例子: MainAcitivity: package com.example.navigation; import android.su ...

  4. JAVA(3)之关于运算符的优先级

    关于运算符的优先级,我做了一个小测试,区别在于平常的运算思维和计算机思维 int result=2; result =(result=result*2)*6*(result=3+result); Sy ...

  5. 吴裕雄 python 神经网络——TensorFlow 使用卷积神经网络训练和预测MNIST手写数据集

    import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_dat ...

  6. 数据分析--excel

    excel 的使用 1.excel基础 1.数据类型 数字类型 字符类型 注意: 1.普通文本:默认作对齐,左上方没有小绿点,数字默认又对齐 2.数字存储为文本类型,美容默认为左对齐,左上方有小绿点 ...

  7. Linux上FTP部署:基于mariadb管理虚拟用户

    FTP原理 FTP 采用 Internet 标准文件传输协议 FTP 的用户界面, 向用户提供了一组用来管理计算机之间文件传输的应用程序.图1 FTP 的基本模型 FTP 是基于客户---服务器(C/ ...

  8. 洛谷 P1043 数字游戏(区间dp)

    题目链接:https://www.luogu.com.cn/problem/P1043 这道题与石子合并很类似,都是把一个环强制改成一个链,然后在链上做区间dp 要初始化出1~2n的前缀和,方便在O( ...

  9. utf-8无bom格式编码

    BOM——Byte Order Mark,就是字节序标记 在UCS 编码中有一个叫做"ZERO WIDTH NO-BREAK SPACE"的字符,它的编码是FEFF.而FFFE在U ...

  10. python中getpass模块

    1 import getpass 2 name = input('请输入你的名字:') 3 passwd = getpass.getpass('请输入你的密码:') 4 print(name) 5 p ...