2012년 1월 17일 화요일

몽고db ( mongodb ) 기본명령어 1 - Collection ( 컬렉션 )

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
}

   

댓글 없음:

댓글 쓰기