mongodb菜鳥教程 怎么用mongodb創(chuàng)建數(shù)據(jù)庫?
怎么用mongodb創(chuàng)建數(shù)據(jù)庫?使用命令mongodbusedatabase Name創(chuàng)建數(shù)據(jù)庫。該命令將創(chuàng)建一個(gè)新的數(shù)據(jù)庫,如果它不存在,否則它將返回現(xiàn)有的數(shù)據(jù)庫。語法:use database語句
怎么用mongodb創(chuàng)建數(shù)據(jù)庫?
使用命令mongodbusedatabase Name創(chuàng)建數(shù)據(jù)庫。該命令將創(chuàng)建一個(gè)新的數(shù)據(jù)庫,如果它不存在,否則它將返回現(xiàn)有的數(shù)據(jù)庫。語法:use database語句的基本語法如下:use databaseuname示例:如果要?jiǎng)?chuàng)建一個(gè)數(shù)據(jù)庫名<mydb>,use database語句如下:>use mydb switched to dbmydb要檢查當(dāng)前選定的數(shù)據(jù)庫,請(qǐng)使用命令DB>db mydb。如果要檢查數(shù)據(jù)庫列表,請(qǐng)使用showdbs命令。>showdbslocal 0.78125gbtest0.23012gb創(chuàng)建不存在的數(shù)據(jù)庫mydb列表。要顯示的數(shù)據(jù)庫,至少需要將其插入到一個(gè)文件中。& gtdb.movie.insert文件({“name”:“tutorial syiibai”})>showdbslocal 0.78125gbmydb0.23012gbtest0.23012gb在mongodb默認(rèn)數(shù)據(jù)庫中測(cè)試。如果沒有創(chuàng)建數(shù)據(jù)庫,則集合存儲(chǔ)在測(cè)試數(shù)據(jù)庫中。