MySQL

Tableplus์—์„œ ๋ณต์›์‹œ ์ธ์ฝ”๋”ฉ์ด ๊นจ์งˆ ๊ฒฝ์šฐ

JoonHo Son
ํŒŒ์ผ ์ž์ฒด๋Š” UTF-8๋กœ ์ •์ƒ์ ์œผ๋กœ ์ž‘์„ฑ๋˜์—ˆ์ง€๋งŒ, ์ด์ƒํ•˜๊ฒŒ TablePlus์—์„œ ๋ณต์›์„ ์‹œํ‚ค๋ฉด ๊นจ์ง€๋”๋ผ. ํŒŒ์ผ์—๋Š” ๋‹จ์ˆœ insert ์ฟผ๋ฆฌ๋งŒ ๋“ค์–ด์žˆ์—ˆ๋‹ค. ํ˜น์‹œ๋‚˜ ํ•˜๋Š” ๋งˆ์Œ์— ๋ณต์›ํ•˜๋Š” ํ™”๋ฉด์—์„œ ์˜ต์…˜ --default-character-set=utf8์„ ๋„ฃ์œผ๋‹ˆ๊นŒ ์ •์ƒ ์ž‘๋™๋˜์—ˆ๋‹ค. << TablePlus์—์„œ ๋ณต์›ํ•˜๋Š” ํ™”๋ฉด >>

JPA + Hibernate์—์„œ DDL script ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๊ธฐ

JoonHo Son
JPA๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋ถ€ํ„ฐ ๊ณ„์† ํ•˜๋ ค๊ณ  ํ–ˆ๋˜๊ฑด๋ฐ, ์ด๋ฒˆ์— ์†Œ๊ธฐ์˜ ๋ชฉ์ ์—์„œ ์•„์ฃผ ์ผ๋ถ€๋ถ„์€ ๋‹ฌ์„ฑํ•˜์—ฌ ์ง„ํ–‰ํ–ˆ๋˜ ๊ณผ์ •์„ ๊ธฐ๋ก์ฐจ์›์—์„œ ๋‚จ๊ธด๋‹ค. ์„ ์š”์•ฝ ์ง€์ •ํ•œ ํŒจํ‚ค์ง€์˜ @Entity annotation์ด ์„ ์–ธ๋œ ํด๋ž˜์Šค๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ DDL script๋ฅผ ํŒŒ์ผ๋กœ ์ƒ์„ฑํ•œ๋‹ค. DDL script ์ƒ์„ฑ์‹œ column comment๋„ ํ•จ๊ป˜ ์ƒ์„ฑํ•œ๋‹ค(์ œ์ผ ๊ณ ๋ฏผ์„ ๋งŽ์ด ํ•จ). @Embedded annotation์ด ๋‹ฌ๋ฆฐ ํ•ญ๋ชฉ๋„ comment๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. TODO Table comment ์ถ”๊ฐ€ Embedded ์ˆœํ™˜ ์ฒ˜๋ฆฌ ๊ตฌํ˜„๋ถ€ ์ž‘์—…์˜ ํ๋ฆ„ ์šฐ์„  Reflections์„ ์ด์šฉํ•˜์—ฌ ์ง€์ •ํ•œ package์•ˆ์— ์กด์žฌํ•˜๋Š” ํด๋ž˜์Šค ์ค‘ @Entity annotation์ด ์„ ์–ธ๋œ ํด๋ž˜์Šค๋ฅผ ๊ฒ€์ƒ‰ํ•œ๋‹ค.

[MySQL] ํŠน์ • ์ด๋ฆ„์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” DB ์ผ๊ด„ ์‚ญ์ œ

JoonHo Son
์—ญ์‹œ ๊ตฌ๊ธ€์€ ๊ฐœ๋ฐœ์ž์˜ ์นœ๊ตฌ~ ์œ ํ›„~ # drop-db.sh DB_STARTS_WITH='sample_' # sample_table1, sample_table2... MUSER="" MPWD="" MYSQL="mysql" DBS="$($MYSQL -u$MUSER -p$MPWD -Bse 'show databases')" for db in $DBS; do if [[ "$db" =~ ^$PDB_STARTS_WITH}" ]]; then echo "Deleting $db" $MYSQL-u$MUSER-p$MPWD-Bse "drop database $db" fi done

[MySQL] ํŠน์ • ์ด๋ฆ„์œผ๋กœ ์‹œ์ž‘ํ•˜๋Š” DB ๋ฐฑ์—… ๋ฐ ๋ณต๊ตฌ

JoonHo Son
์‚ฝ์งˆ + ๊ตฌ๊ธ€๋ง์œผ๋กœ ์™„์„ฑ. ๊ฐ๊ฐ์˜ ์ด๋ฏธ์ง€๋Š” ๋‹ค์Œ ๋งํฌ ์ฐธ์กฐ(gist) backup : https://gist.github.com/JoonHoSon/56cd2cfe5efa36d60d14473e19ecba92#file-backup-sh restore : https://gist.github.com/JoonHoSon/56cd2cfe5efa36d60d14473e19ecba92#file-restore-sh << backup >> << restore >>