夺命雷公狗mongodb之----mongodb---2---常用命令和技巧

查看有那些数据库:
show dbs
切换到那个库:
use 库名
use local
use还有一个作用就是可以“创建一个数据库”
use test
删除数据库:
db.dropDatabase();
查看集合:
show collections
创建集合:
db.createCollection("user");
隐式创建,直接插入集合,她会自动创建集合
db.user.insert({id:1,name:"lisi"});
删除集合:
db.user.drop();
插入:
db.user.insert({id:1,name:"lisi",sex:"1"});
查询:
db.user.find()
修改:
db.user.update({id:1},{name:'lisi',sex:''});
删除:
db.user.remove({name:'lisi'});
如果同时insert两个一样的参数则会被后面的覆盖
db.user.insert({x:2,x:3});
在mongodb里面是严格区分大小写的
如果在实际开发中如果想让时间变成非字符串的形式可以通过new Date方法进行插入数据:
db.user.insert({name:'lisi',addTime:new Date()});
如果直接是Date()这样的则是以字符串形式创建的
如果在打印时候不想看到他打印出默认生成的那堆_id串,那么我们可以通过如下方法来进行查询:
db.user.find({},{_id:0});
如果_id:1那么就是打印出默认的_id
夺命雷公狗mongodb之----mongodb---2---常用命令和技巧的更多相关文章
- 夺命雷公狗-----React---12--添加类和样式
<!DOCTYPE> <html> <head> <meta charset="utf-8"> <title></ ...
- 夺命雷公狗-----React---11--添加css样式的方法
<!DOCTYPE> <html> <head> <meta charset="utf-8"> <title></ ...
- 夺命雷公狗-----React---10--组建嵌套进行数据遍历
先写一个组建... 然后进行嵌套.. <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- 夺命雷公狗-----React---9--map数据的遍历
比如我们要实现的是这种效果: 用这种方法来写,她只能写死在哪,没啥意思,所以我们定义一个数据,然后来测试下map方法对她遍历出来的数据 <!DOCTYPE html> <html l ...
- 夺命雷公狗-----React---8--react官方提供的组建实现双向绑定
首先要引入她.. <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- 夺命雷公狗-----React---7--组建的状态props和state
props:组建初始要渲染的数据,他是不可以改变的 state:组建状态发生改变,调用render重新渲染数据 我们来写一个例子: <!DOCTYPE html> <html lan ...
- 夺命雷公狗-----React---6--props多属性的传递
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 夺命雷公狗-----React---5--props对象的传递
提示:props的值是不可以改变的... <!DOCTYPE html> <html lang="en"> <head> <meta ch ...
- 夺命雷公狗-----React---4--props变量的传递
提示:props的值是不可以改变的... <!DOCTYPE html> <html lang="en"> <head> <meta ch ...
- 夺命雷公狗-----React---3--标签的规则
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- Cygwin + CMake 测试
https://www.cygwin.com/ apt-get for cygwin? wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg in ...
- C/C++ 笔试、面试题目大汇总(二)
一.找错题 试题1: void test1() { charstring[10]; char* str1 ="0123456789"; strcpy( string, str1 ) ...
- [LeetCode]题解(python):111 Minimum Depth of Binary Tree
题目来源 https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minim ...
- 10 Ways to Inspire Your Team
Inspire. Just the word itself causes us to pause and think. We may remember our own personal heroes ...
- http://blog.csdn.net/tiantiandjava/article/details/46777051
http://blog.csdn.net/tiantiandjava/article/details/46777051
- iOS单例模式
单例模式用于当一个类只能有一个实例的时候, 通常情况下这个“单例”代表的是某一个物理设备比如打印机,或是某种不可以有多个实例同时存在的虚拟资源或是系统属性比如一个程序的某个引擎或是数据.用单例模式加以 ...
- Using dbms_shared_pool.purge to remove a single task from the library cache
我们都知道可是使用 alter system flush shared_pool 来清除shared pool 信息,当时不能指定清除某个对象.因为在系统繁忙的时侯 使用 alter system f ...
- python笔记 - day6
python笔记 - day6 参考: http://www.cnblogs.com/wupeiqi/articles/5501365.html 大纲: 利用递归,实现阶乘: Python反射 pyt ...
- extern 和 static和 今天的一些代码,12-03
这是关于标识符的链接属性的,链接属性只有三种:external, internal, none 改变规则: 3.1 文件作用域的变量和函数定义,即在所有 代码块和参数列表之外的标识符,使用static ...
- Which Python memory profiler is recommended
http://stackoverflow.com/questions/110259/which-Python-memory-profiler-is-recommended/110826#110826