1 創(chuàng)建數(shù)據(jù)庫并插入數(shù)據(jù)
1
2
3
4
|
use jinxt db.adou. insert ({ name : "jinxt" ,age: "28" }); //剛創(chuàng)建的數(shù)據(jù)庫 jinxt并不在數(shù)據(jù)庫的列表中, 要顯示它,我們需要向 jinxt數(shù)據(jù)庫插入一些數(shù)據(jù) show dbs db.dropDatabase(); //刪除數(shù)據(jù)庫 |
2 插入文檔
1
2
3
4
5
|
use jinxt db.adou. insert ({ name : "jinxt" ,age:28,sex: "男" ,tags:[ "高大" , "威武" , "雄壯" ]}); document=({ name : "jinxt2" ,age:29,sex: "男" ,tags:[ "高大" , "威武" , "雄壯" ]}); db.adou. insert (document); db.adou.find(); |
以上所述是小編給大家介紹的MongoDB插入、更新、刪除文檔,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網(wǎng)站的支持!
原文鏈接:http://www.cnblogs.com/jinxt/archive/2017/04/25/6761368.html