在SqlServer和Oralce中创建索引
给表名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中创建索引的更多相关文章
- elasticsearch kabana中创建索引
在kabana中创建索引和索引类型语法 PUT clockin{ "mappings": { "time": { } }} 查询索引下的所有数据 GET clo ...
- SqlServer在视图上创建索引
在视图上创建索引需要三个条件: 一.视图必须绑定到架构. 要做到这点,在 CREATE VIEW 语句中,必须加上 WITH SCHEMABINDING,如果是使用企业管理器,则在设计界面的空白处点击 ...
- HBase中创建索引
hbasene(https://github.com/akkumar/hbasene)是开源项目,在hbase存储上封装使用Lucene来创建索引,代码API非常简单,熟悉lucene的朋友可以很方便 ...
- Mysql 中创建索引和索引的使用问题
在数据库中合理的使用索引是提升mysql数据库的一种高效和快捷的方式,但是在索引的使用上在我的使用中发现有很多坑,因为自己之前没有认识到,所以来总结一下 索引的介绍 索引是一种特殊的文件,其中包含着对 ...
- lucene中创建索引库
package com.hope.lucene;import org.apache.commons.io.FileUtils;import org.apache.lucene.document.Doc ...
- sqlserver 生成脚本执行创建索引
create or alter proc SP_CreateIndex as begin if exists(select * from sys.objects where name='execsql ...
- MySql SqlServer Sqlite中关于索引的创建
最近要更新Cocon90.Db库,令其ORM创建表时实现索引的添加.因此总结下列常用Sql,供大家学习与参考. 一.SqlServer中创建索引可以这样: ) Create Table Test ( ...
- SQLSERVER 创建索引实现代码
是SQL Server编排数据的内部方法.它为SQL Server提供一种方法来编排查询数据 什么是索引 拿汉语字典的目录页(索引)打比方:正如汉语字典中的汉字按页存放一样,SQL Server中的数 ...
- hive中的索引创建
1.在hive中创建索引所在表 create table if not exists h_odse.hxy(id int,name string,hobby array<string>,a ...
随机推荐
- Anaconda+tensorflow(不用创建虚拟环境)
网上大部分教程都是:创建tensorflow虚拟环境(conda create -n tensorflow python=3.6),然后在虚拟环境中pip install tensorflow,但是每 ...
- 攻防世界CRYPTO新手练习
0x01 base64 直接base64 Decode 得到flag cyberpeace{Welcome_to_new_World!} 0x02 Caesar key为12 的恺撒密码,解密德fla ...
- 01.04 linux命令(2
======================Linux下的用户管理==============用户信息保存/etc/passwd ,一般用户都有读的权限真正的用户:修改密码,可以登录伪用户:应用程序在 ...
- 彻底搞定Javascript事件循环
参考链接:https://juejin.im/post/5dca8a8be51d45227239abc4?utm_medium=hao.caibaojian.com&utm_source=ha ...
- Unsupported major.minor version 52.0——解决
Unsupported major.minor version 52.0 就是编辑用的是jdk8 而运行用的是jdk7, 改成jdk8就好了 参考文章:https://blog.csdn.net/qq ...
- poj1915(双向bfs)
题目链接:https://vjudge.net/problem/POJ-1915 题意:求棋盘上起点到终点最少的步数. 思路:双向广搜模板题,但玄学的是我的代码G++会wa,C++过了,没找到原因QA ...
- 【转帖】MBW内存测试
MBW内存测试 https://www.cnblogs.com/dongdongwq/p/5431561.html 在测试前,理应了解本机所具备的特点,比如CPU频率.内存频率.内存大小,等等信息. ...
- 解决redis运行期间key值过期但是内存memory依然占用过高
要解决这个问题,首先要了解redis info信息中几个数据的意义: used_memory:810575104 //数据占用了多少内存(字节) used_memory_human:773.02 ...
- 服务器做raid1后安装windows server 2012遇到的问题
问题: 在服务器上用2个300G的硬盘做了raid1之后,其他的盘做的raid5,安装windows server 2012的时候,到安装界面发现raid1的那个盘是600G,而且在这个磁盘上安装操作 ...
- [HihoCoder-1424] Asa's Chess Problem
有上下界的费用流 #include <stdio.h> #include <algorithm> #include <queue> #include <cst ...