索引属性 name指定
db.collection.ensureIndex({param},{param})
名字
db.collection.ensureIndex({},{name:''})
在创建索引时,mongodb会自己给索引创建默认的名字,这种名字并不好记,我们看一下mongodb是怎么给自己命名的
唯一性
稀疏性
是否定时删除:比如过期索引
> db.suoyin.getIndexes()
[
{
"v" : ,
"key" : {
"_id" :
},
"name" : "_id_",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" :
},
"name" : "x_1",
"ns" : "test.suoyin"
}
]
> db.suoyin.getIndexes()
[
{
"v" : ,
"key" : {
"_id" :
},
"name" : "_id_",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" :
},
"name" : "x_1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"y" : -
},
"name" : "y_-1",
"ns" : "test.suoyin"
}
]
> db.suoyin.ensureIndex({x:,y:-})
> db.suoyin.getIndexes()
[
{
"v" : ,
"key" : {
"_id" :
},
"name" : "_id_",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" :
},
"name" : "x_1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"y" : -
},
"name" : "y_-1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" : ,
"y" : -
},
"name" : "x_1_y_-1",
"ns" : "test.suoyin"
}
]
> db.suoyin.ensureIndex({x:,y:,z:,m:},{name:'normal_index'})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : ,
"numIndexesAfter" : ,
"ok" :
}
> db.suoyin.getIndexes()
[
{
"v" : ,
"key" : {
"_id" :
},
"name" : "_id_",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" :
},
"name" : "x_1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"y" : -
},
"name" : "y_-1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" : ,
"y" : -
},
"name" : "x_1_y_-1",
"ns" : "test.suoyin"
},
{
"v" : ,
"key" : {
"x" : ,
"y" : ,
"z" : ,
"m" :
},
"name" : "normal_index",
"ns" : "test.suoyin"
}
]
> db.suoyin.dropIndex('normal_index')
{ "nIndexesWas" : , "ok" : }
> db.suoyin.getIndexes()
[
{
"v" : ,
"key" : {
"_id" :
},
"name" : "_id_",
"ns" : "test.suoyin"
}
]
索引属性 name指定的更多相关文章
- 索引属性 unique指定
比较重要的属性有: 名字 db.collection.ensureIndex({},{name:''}) 在创建索引时,mongodb会自己给索引创建默认的名字,这种名字并不好记,我们看一下mongo ...
- 攻城狮在路上(壹) Hibernate(三)--- 属性访问、命名策略、派生属性、指定包名等
一.hibernate访问持久化类属性的策略: 在<property>元素中的access属性用于指定Hibernate访问持久化类属性的方式. 常见的方式如下: 1.property:默 ...
- box-sizing属性(指定针对元素的宽度与高度的计算方法)
在css中,使用width属性与height属性来指定元素的宽度与高度.使用box-sizing属性,可以指定用width属性与height属性分别指定的宽度值与高度值是否包含元素的内部补白区域与边框 ...
- 利用pandas选取某个属性符合指定条件的所有行
最近遇到利用pandas选取指定行的需求,经常忘记,在此做下记录 选取某个属性等于特定值的所有行记录 df[(df[‘column_name’] == target_value)] 注:等于用 '== ...
- arcpy显示指定表的索引属性
import arcpy feature_class = "c:/data/well.shp" # Create a list of indexes using the ListI ...
- Spring对外部属性文件指定的某个属性进行加密、解密
[From] http://blog.csdn.net/ethanq/article/details/7333897 在我们开发当中,经常会用到spring框架来读取属性文件的属性值,然后使用占位符引 ...
- html -- contenteditable 属性:指定元素内容是否可编辑
所有主流浏览器都支持 contenteditable 属性 定义和用法 contenteditable 属性指定元素内容是否可编辑. 注意: 当元素中没有设置 contenteditable 属性时, ...
- Java属性中指定Json的属性名称
只需要使用注解"@JsonProperty(value = "pwd")" import com.fasterxml.jackson.annotation.Js ...
- 正则去除html标签属性保留指定标签
/// <summary> /// 去除标签里面的属性保留IMG标签属性 /// </summary> /// <param name="strText&quo ...
随机推荐
- Exceptionless - .Net Core开源日志框架
Exceptionless - .Net Core开源日志框架 作者:markjiang7m2 原文地址:https://www.cnblogs.com/markjiang7m2/p/11020140 ...
- java加密MD5实现及密码验证
package test; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; impor ...
- 洛谷P3533 [POI2012]RAN-Rendezvous
P3533 [POI2012]RAN-Rendezvous 题目描述 Byteasar is a ranger who works in the Arrow Cave - a famous rende ...
- IdentityServer4 学习笔记[1]-客户端授权
前言 本文内容来自IdentityServer4官网,官网有详细的介绍,并且有源码Demo 官网源码例子传送门 建立授权服务端 我们暂时不配置Https,选择空模板建立项目,项目建立后, 为了查看de ...
- Orthanc+OHIF DICOM Viewer最佳Dicom解析、在线浏览实践指南(解决方案)
概念 DICOM identifiers Very importantly, the DICOM standard specifies DICOM tags that allow to index e ...
- UVA12230 过河 Crossing Rivers
题目描述 一个人每天需要从家去往公司,然后家与公司的道路是条直线,长度为 \(D\). 同时路上有 \(N\)条河,给出起点和宽度\(W_i\) , 过河需要乘坐速度为\(V_i\) 的渡船; 船在河 ...
- webpack安装及使用
npm run dev 第一次使用的时候用u盘将某些软件带过去. 所以要找到U盘 2.9.x的版本[推荐] 安装:npm install -g vue-cli 检测版本 vue -V/--versio ...
- MySQL库改名、表改名
数据库中的库或表在开发环境下可能需要改名,关于MySQL的改名步骤如下: 1.备份数据库,备份后就可以安心的去改名了,如果操作错误还可以及时恢复 mysqldump -R -uroot -p 数据库名 ...
- 解决Eclipse导入Gradle项目时在 Building gradle project info 一直卡住
问题描述 在使用 Eclipse 导入 Gradle 项目时一直卡住,不能导入项目 问题解决 解决办法主要有两种:一是直接下载 gradle 离线包,二是修改项目的 ..\gradle\wrapp ...
- python排序(冒泡、直接选择、直接插入等)
冒泡排序 冒泡法:第一趟:相邻的两数相比,大的往下沉.最后一个元素是最大的. 第二趟:相邻的两数相比,大的往下沉.最后一个元素不用比. #冒泡排序 array = [1,5,6,2,9,4,3] de ...