[Guide] Songs 테이블 bulk insert 및 DB 더미 데이터 추가
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### songs 테이블 bulk insert
- local_infile을 true로 설정 (최초 한 번만 설정해도 무관)
```
set global local_infile=true;
```
- 노래 데이터가 담긴 csv 파일이 있는 디렉토리 안에서 아래 명령어 실행
```
load data local infile "파일이름.csv" into table songs fields terminated by ",";
```
### songs 테이블 초기화
- Foreign key (다대다 관계) 무시
```
set FOREIGN_KEY_CHECKS = 0;
```
- 테이블 초기화 (id 1부터 리셋되도록 설정)
```
truncate table songs;
```
- Bulk insert 후, foreign key (다대다 관계) 재설정
```
set FOREIGN_KEY_CHECKS = 1;
```
### hashtaglikes 테이블 데이터 추가
```
INSERT INTO hashtaglikes(name) VALUES
("좋아요"),("#인생곡인"),("#가사가재밌는"),("#몸이기억하는"),("#눈물샘자극"),("#노래방금지곡"),("#영원한18번"),("#추억소환");
```
id=1이 "좋아요"입니다.
### users 테이블 더미 데이터 추가
```
INSERT INTO users(nickname, email, salt, password, birthYear, kakao) VALUES (
"김경호#숫자아무거나", "m4m@gmail.com", "1234", "1234", 1990, false
);
```
### comments 테이블 더미 데이터 추가
```
// DB에 존재하는 userId와 songId로 변경해서 추가해주세요
INSERT INTO comments(userId, songId, content) VALUES (
1, 1, "댓글 내용"
);
```
### songuserhashtaglikes 테이블 더미 데이터 추가
```
// DB에 존재하는 userId와 songId로 변경해서 추가해주세요
INSERT INTO songuserhashtaglikes(userId, songId, hashtagId) VALUES (
1, 1, 1
);
```
### ERROR 1364 (HY000): Field 'createdAt' doesn't have a default value) 에러 발생 시, 아래 명령어 실행
```
ALTER TABLE 테이블이름 CHANGE COLUMN createdAt createdAt datetime NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE 테이블이름 CHANGE COLUMN updatedAt updatedAt datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.