zoukankan      html  css  js  c++  java
  • 用与不用聚集索引的区别 sql用例

    if not object_id('test_no_cx') is null
    drop table test_no_cx
    if not object_id('test_has_cx') is null
    drop table test_has_cx

    --创建一个不含索引的表test_no_cx
    create table test_no_cx(id int, name varchar(20), createtime datetime default(getdate()))


    --插入若干条记录(注意:这里故意打乱id的顺序)
    insert test_no_cx(id, name) values(100,'100''s value')

    insert test_no_cx(id, name) values(5,'5''s value')
    insert test_no_cx(id, name) values(90,'90''s value')

    --创建含索引的表test_no_cx
    create table test_has_cx(id int, name varchar(20), createtime datetime default(getdate()))

    create clustered index ix_test_has_cx on test_has_cx(id)

    --将test_no_cx中的记录批量插入到test_has_cx中
    insert test_has_cx select * from test_no_cx


    --此时比较两表的记录如下:
    
    


    --向两表中插入一条同样的记录
    insert test_no_cx(id, name) values(50,'50''s value')

    insert test_has_cx(id, name) values(50,'50''s value')

    --此时比较两表的记录如下:
    
    

     注:以上sql可直接运行。

  • 相关阅读:
    ubuntu nginx 伪静态 设置
    ubuntu thinkphp pathinfo 404等问题
    ubuntu svn安装测试
    ubuntu zendDebugger.so 加载不上的问题
    ubuntu ssh安装
    nyoj-660-逃离地球
    nyoj-643-发短信
    nyoj-181-小明的难题
    nyoj-663-弟弟的作业
    nyoj-682-初学者的烦恼
  • 原文地址:https://www.cnblogs.com/moss_tan_jun/p/2263965.html
Copyright © 2011-2022 走看看