時間:2024-02-28 13:28作者:下載吧人氣:17
mongodb是基于分布式文件存儲的nosql(非關系型)數(shù)據(jù)庫
雖說是nosqldb, but mongodb 其中的文檔可以是關系型的
在mongodb中, 表為集合, 里面的數(shù)據(jù)為文檔; 文檔本質(zhì)就是一條調(diào)JSON數(shù)據(jù)
進入mongodb: mongo
退出mongodb: exit
庫操作
顯示庫: show dbs
選擇或者創(chuàng)建: use llsdb
# 不管該庫是否存在,都會use進入, 如何該庫不存在, use進去不存入數(shù)據(jù)退出時,該庫 不會被創(chuàng)建. 所以創(chuàng)建庫就use再寫入數(shù)據(jù).
查看所在庫: db
刪除庫: db.dropDatabase()
,要先use進入庫才刪除.
集合操作
顯示集合: show collections
創(chuàng)建集合: db.createCollection('llscol' [,options])
刪除集合: db.llscol.drop()
數(shù)據(jù)的CURD
插入數(shù)據(jù): db.llscol.insert({name: 'lls', age: 18})
插入多條數(shù)據(jù):
db.llscol.insert([ {name: 'lls1', age: 18}, {name: 'lls2', age: 20} ])
網(wǎng)友評論