给表名A的字段A增加索引

SqlServer:

if exists (select 1 from sysobjects where name='表名A' and type='u')
and exists (select 1 from syscolumns where name='字段A' and id=object_id('表名A'))
and not exists(select 1 from sys.indexes where object_id = OBJECT_ID('表名A') and name = '索引名称')
begin
exec('create index 索引名称 on 表名A(字段)')
end
go

Oralce:

declare vCount1 int := 0 ;
vCount2 int := 0 ;
begin
select count(1) into vCount1 from user_all_tables where upper(Table_Name) = upper('表名A');
select count(1) into vCount2 from user_tab_columns where upper(Table_Name) = upper('表名A') and upper(column_name) = upper('字段A');
if(vCount1 > 0 and vCount2 > 0 ) then
vCount1 := 0;
select count(1) into vCount1 from user_indexes where upper(table_Name) = upper('表名A') and upper(Index_Name) = upper('索引名');
if(vCount1 = 0) then
execute immediate ('CREATE INDEX 索引名 ON 表名A(字段A)');
end if;
end if;
end;

在SqlServer和Oralce中创建索引的更多相关文章

  1. elasticsearch kabana中创建索引

    在kabana中创建索引和索引类型语法 PUT clockin{ "mappings": { "time": { } }} 查询索引下的所有数据 GET clo ...

  2. SqlServer在视图上创建索引

    在视图上创建索引需要三个条件: 一.视图必须绑定到架构. 要做到这点,在 CREATE VIEW 语句中,必须加上 WITH SCHEMABINDING,如果是使用企业管理器,则在设计界面的空白处点击 ...

  3. HBase中创建索引

    hbasene(https://github.com/akkumar/hbasene)是开源项目,在hbase存储上封装使用Lucene来创建索引,代码API非常简单,熟悉lucene的朋友可以很方便 ...

  4. Mysql 中创建索引和索引的使用问题

    在数据库中合理的使用索引是提升mysql数据库的一种高效和快捷的方式,但是在索引的使用上在我的使用中发现有很多坑,因为自己之前没有认识到,所以来总结一下 索引的介绍 索引是一种特殊的文件,其中包含着对 ...

  5. lucene中创建索引库

    package com.hope.lucene;import org.apache.commons.io.FileUtils;import org.apache.lucene.document.Doc ...

  6. sqlserver 生成脚本执行创建索引

    create or alter proc SP_CreateIndex as begin if exists(select * from sys.objects where name='execsql ...

  7. MySql SqlServer Sqlite中关于索引的创建

    最近要更新Cocon90.Db库,令其ORM创建表时实现索引的添加.因此总结下列常用Sql,供大家学习与参考. 一.SqlServer中创建索引可以这样: ) Create Table Test ( ...

  8. SQLSERVER 创建索引实现代码

    是SQL Server编排数据的内部方法.它为SQL Server提供一种方法来编排查询数据 什么是索引 拿汉语字典的目录页(索引)打比方:正如汉语字典中的汉字按页存放一样,SQL Server中的数 ...

  9. hive中的索引创建

    1.在hive中创建索引所在表 create table if not exists h_odse.hxy(id int,name string,hobby array<string>,a ...

随机推荐

  1. windows下配置tomcat服务器的jvm内存大小的两种方式

    难得遇到一次java堆内存溢出(心里想着,终于可以来一次jvm性能优化了$$) 先看下报错信息, java.lang.OutOfMemoryError: GC overhead limit excee ...

  2. Flutter的闪屏动画案例AnimationController

    打开一个APP,经常会看到精美的启动页,这种启动页也称为闪屏动画.它是从无到有有一个透明度的渐变动画的.图像展示完事后,才跳转到用户可操作的页面. AnimationController Animat ...

  3. PHP中include、require、include_once、require_once的区别

    include:使用include引用外部文件时,只有代码执行到include代码段时,调用的外部文件才会被引用并读取,当引用的文件发生错误时,系统只会给出个警告错误,而整个php文件会继续执行.re ...

  4. QFramework 使用指南 2020(五):脚本生成(3)生成 Prefab

    在上一篇,我们简单介绍了 ViewController 的嵌套实现. 在这一篇,我们学习 ViewController 脚本生成的最后一个功能,即:生成 Prefab. 实际上这个功能非常简单. 我们 ...

  5. list集合的一些小见解

    关于LIst集合 前言: 第一次写博客,有些东西可能总结的到位,发表一下自己的一些观点,欢迎大佬们点评和指教 正文: list集合可以分为ArrayLlst和LinkedList. ArrayList ...

  6. Linux安装jemalloc笔记

    前言 最近研究一个工具库需要用 jemalloc 做内存分配器,但在 ubuntu 下安装过程中遇到很多问题,故记下安装过程的笔记,避免以后遇到在这上面浪费时间. 安装过程 环境:VMware Ubu ...

  7. 【AtCoder】ARC058

    ARC058 C - こだわり者いろはちゃん / Iroha's Obsession 暴力一个个枚举是最简单的方式 #include <bits/stdc++.h> #define fi ...

  8. 【AtCoder】AGC001

    AGC001 A - BBQ Easy 从第\(2n - 1\)个隔一个加一下加到1即可 #include <bits/stdc++.h> #define fi first #define ...

  9. 【AtCoder】CODE FESTIVAL 2016 qual A

    CODE FESTIVAL 2016 qual A A - CODEFESTIVAL 2016 -- #include <bits/stdc++.h> #define fi first # ...

  10. idea配置glassFish启动项目

    将项目打成war包形式. 然后配置glassFish +号配置启动包 此处配置启动路径 ........ 路径也可以在localhost:4848 --->中的Applicaton中去配置