반응형
CREATE (생성)
- INSERT INTO [테이블명] ([컬럼1], [컬럼2], ...) VALUES ([값1], [값2], ...);
mysql> INSERT INTO nodejs.users (name, age, married, comment) VALUES ('zero', 24, 0, '자기소개1');
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO nodejs.users (name, age, married, comment) VALUES ('nero', 32, 1, '자기소개2');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO nodejs.comments (commenter, comment) VALUES ('1','댓글1');
Query OK, 1 row affected (0.00 sec)
READ (조회)
- SELECT * FROM [테이블명];
mysql> SELECT * FROM nodejs.users;
+----+------+-----+---------+---------------+---------------------+
| id | name | age | married | comment | created_at |
+----+------+-----+---------+---------------+---------------------+
| 1 | zero | 24 | 0 | 자기소개1 | 2019-09-22 15:18:49 |
| 2 | nero | 32 | 1 | 자기소개2 | 2019-09-22 15:19:07 |
+----+------+-----+---------+---------------+---------------------+
2 rows in set (0.01 sec)
UPDATE (수정)
- UPDATE [테이블명] SET [컬럼명=바꿀 값] WHERE [조건];
mysql> UPDATE nodejs.users SET comment = '바꿀내용' WHERE id = 2;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
DELETE (삭제)
- DELETE FROM [테이블명] WHERE [조건];
mysql> DELETE FROM nodejs.users WHERE id = 2;
Query OK, 1 row affected (0.00 sec)
반응형
'Database > MySQL' 카테고리의 다른 글
[MySQL] DataTime <> UnixTime 표기 변환 (0) | 2020.07.22 |
---|---|
[MySQL][MyBatis] Query null 처리 방법에 대한 고찰 (0) | 2020.07.22 |
[MySQL] 테스트 데이터베이스 생성 및 사용 (0) | 2019.11.16 |