반응형

출처:http://jmkook77.blogspot.kr/2012/01/db-mongodb-collection.html



Mongodb Collection

 1) 컬렉션 생성

   > use dbName;
   > db.createCollection("test1");

   { "ok" : 1 }

   > show collections;

   system.indexes
   test1

   > # Capped Collection ( 제한사이즈로 설정하며 성능적으로 유리함. 단, 제한사항을 가지므로http://www.mongodb.org/display/DOCS/Capped+Collections#CappedCollections-UsageandRestrictions 에서 확인 필요 ) 

   > db.createCollection("test1", {capped:true, size:100000, max: 1000});

 { "ok" : 1 }

   > show collections;

   system.indexes
   test1


 2) 컬렉션명 수정

   > db.collectionName.renameCollection("newCollectionName");


   { "ok" : 1 }

   > show collections;

   system.indexes
   test2

 3) 컬렉션 삭제

   > db.test2.drop();

   true

   > show collections;

   system.indexes

 4) 컬렉션 상태 보기

   > db.test3.validate();

{
"ns" : "test.test3",
"capped" : 1,
"max" : 2147483647,
"firstExtent" : "0:25000 ns:test.test3",
"lastExtent" : "0:25000 ns:test.test3",
"extentCount" : 1,
"datasize" : 0,
"nrecords" : 0,
"lastExtentSize" : 102400,
"padding" : 1,
"firstExtentDetails" : {
"loc" : "0:25000",
"xnext" : "null",
"xprev" : "null",
"nsdiag" : "test.test3",
"size" : 102400,
"firstRecord" : "null",
"lastRecord" : "null"
},
"deletedCount" : 2,
"deletedSize" : 102224,
"nIndexes" : 0,
"keysPerIndex" : {
},
"valid" : true,
"errors" : [ ],
"warning" : "Some checks omitted for speed. use {full:true} option to do more thorough scan.",
"ok" : 1
}


반응형

'프로젝트 관련 조사 > DB' 카테고리의 다른 글

MongoDB 조회하기  (0) 2015.10.29
SQL문법과 MongoDB 문법 비교 분석  (0) 2015.10.29
MongoDB 용어 설명  (0) 2015.10.29
MongoDB 란?  (0) 2015.10.29
우분투에 mongo DB 구축  (0) 2015.10.16

+ Recent posts