Mongo技巧-连接数据库与修改表结构
2015-11-03 10:21
295 查看
1. 连接非本机数据库
mongo.exe之后直接输入ip地址即可mongo.exe 192.168.163.203
2. 修改表结构
mongo里面没有表结构这个概念,现在采用类似关系型数据库的形式来描述。如果想去掉collection里面的一个key,可以采用以下命令:db.UserEntity.update({},{$unset:{Mail:1}},false,true);
上面的命令从表UserEntity中删除一个字段Mail。
关于unset的具体说明
$unset The $unset operator deletes a particular field. Consider the following syntax: { $unset: { <field1>: "", ... } } The specified value in the $unset expression (i.e. "") does not impact the operation. To specify a <field> in an embedded document or in an array, use dot notation. Behavior If the field does not exist, then $unset does nothing (i.e. no operation). When used with $ to match an array element, $unset replaces the matching element with null rather than removing the matching element from the array. This behavior keeps consistent the array size and element positions. Example The following update() operation uses the $unset operator to remove the fields quantity and instock from the first document in the products collection where the field sku has a value of unknown. db.products.update( { sku: "unknown" }, { $unset: { quantity: "", instock: "" } } ) SEE ALSO
相关文章推荐
- is [not] distinct from 的 null 比较
- SQL SERVER 2008 64位系统无法导入ACCESS/EXCEL怎么办
- 第一次写oracle触发器,记录一下
- O5 - sqlite读取db文件
- MySql中分组简介
- mysqli扩展库应用---批量执行sql语句
- 常用数据库中的翻页查询语句
- 解决PLSQL提示 is not a valid date and time
- redis集群实战
- 安装redis和phpredis模块
- Redis 命令速查表
- Redis Windows 安装使用及数据存储
- mysql 定时任务
- oracle 游标
- Mongodb学习笔记(一)
- oracle添加主键自增长
- MySql导入导出数据库命令
- Redis Cluster 3.0.5 集群实战
- mysql扩展中常用函数
- SQL SERVER安装提示“安装了 Microsoft Visual Studio 2008 的早期版本