2016. 7. 12.

MongoDB CRUD 간략 기능만

데이터베이스 만들기

use 명령어

use [db명] 으로 데이터 베이스를 이동할 수 있지만, [db명]이 존재하지 않을때에는 자동으로 새로운 db를 생성해 줍니다.

db.users.insert({username:”hello”})

를 통해서 테이블(?)을 추가할 수 있습니다. 하지만, 계속 같은 입력을 하면, 중복되는 값이 추가가 됩니다.

collection 정보 읽어오기

db.users.find()

db.users 안에 담긴 모든 정보를 읽어오는 명령어 입니다.

db.users.find({username:”hello”})

username이 hello 인 사람의 정보만 읽어오기.

collection 추가/변경 하기

db.users.update({username:”hello},{$set: {phone:”010-4947-1234”})

username 이 hello 인 정보에 phone 정보를 추가/변경 하는 명령어 입니다.

삭제하기

db.users.remove({username:”hello”})

username 이 hello인 정보를 갖고 있는 collection을 지우는 명령어

댓글 없음:

댓글 쓰기