๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[DB] SQL&Database ๋๋‚ด๊ธฐ - LIKE, %, _ ์—ฐ์‚ฐ์ž (5)

DBeaver - MySQL ๋กœ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. WHERE ์กฐ๊ฑด์‹ ์ž๋ฆฌ์— LIKE ์—ฐ์‚ฐ์ž๊ฐ€ ์˜ฌ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์›ํ•˜๋Š” ๋‹จ์–ด๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.- '% %',  '_' ์ฒ˜๋Ÿผ ๋”ฐ์˜ดํ‘œ(')ํ•˜๋Š” ๊ฑฐ ์ฃผ์˜ํ•˜๊ธฐ- LIKE๋„ ๋น„๊ต ์—ฐ์‚ฐ์ž์ด๊ธฐ ๋•Œ๋ฌธ์— [์ƒํ’ˆ๋ช… = '๊ฐ€๊ตฌ'] ์ฒ˜๋Ÿผ ๋“ฑํ˜ธ ์œ„์น˜์— LIKE๊ฐ€ ์“ฐ์—ฌ์š”. ๊ทธ๋ž˜์„œ [์ƒํ’ˆ๋ช… LIKE '%๊ฐ€๊ตฌ%']๋กœ ์จ์•ผ ํ•ด์š”. %๋Š” ๋ชจ๋“  ๊ธ€์ž์ˆ˜๋ฅผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.- ๋‚˜๋ฌด ์‹œ์ž‘ ๋‹จ์–ด ๊ฒ€์ƒ‰: '%๋‚˜๋ฌด'- ๋‚˜๋ฌด ์ค‘๊ฐ„ ๋‹จ์–ด ๊ฒ€์ƒ‰: '%๋‚˜๋ฌด%'- ๋‚˜๋ฌด ์ข…๋ฃŒ ๋‹จ์–ด ๊ฒ€์ƒ‰: '๋‚˜๋ฌด%' _๋„ %์™€ ๋™์ผํ•œ๋ฐ, ๊ธ€์ž ์ˆ˜๋งŒํผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.- ๋‚˜๋ฌด ์‹œ์ž‘ ๋‹จ์–ด ๊ฒ€์ƒ‰: '__๋‚˜๋ฌด' > ๋‚˜๋ฌด ์•ž 2์ž๋ฆฌ ๊ฒ€์ƒ‰- ๋‚˜๋ฌด ์‹œ์ž‘ ๋‹จ์–ด ๊ฒ€์ƒ‰: '_๋‚˜๋ฌด'   > ๋‚˜๋ฌด ์•ž 1์ž๋ฆฌ ๊ฒ€์ƒ‰ (์‚ฌ์šฉ๋ฐฉ๋ฒ•)$ SELECT * FROM p..

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[DB] SQL&Database ๋๋‚ด๊ธฐ - ๋ฐ์ดํ„ฐ ํ•„ํ„ฐ๋ง(WHERE) (4)

DBeaver - MySQL ๋กœ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ํ•„ํ„ฐ๋ง ์–ธ์ œ? ๋ฐ์ดํ„ฐ ํŠน์ • ํ–‰์„ ํ•„ํ„ฐ๋งํ•  ๋•Œ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.- ํ•„ํ„ฐ๋ง: WHERE- ๋“ฑํ˜ธ: >, - ๋ถ€์ • ๋“ฑํ˜ธ: NOT, !=   - ์ด๋•Œ, NOT์€ WHERE ์˜†์— ์‚ฌ์šฉ๋จ Q. product ํ…Œ์ด๋ธ”์—์„œ ๊ฐ€๊ฒฉ์ด 5000์ด์ƒ์ธ ํ–‰์„ ์ถœ๋ ฅ $ SELECT * FROM product WHERE ๊ฐ€๊ฒฉ > 5000 Q. 5000์ด์ƒ ์ด๊ณ  8000 ์ดํ•˜์ธ ํ–‰ ์ถœ๋ ฅ$ SELECT * FROM product WHERE ๊ฐ€๊ฒฉ BETWEEN 5000 AND 8000 Q. product ํ…Œ์ด๋ธ”์—์„œ ๊ฐ€๊ฒฉ์ด 5000์ด์ƒ์ด ์•„๋‹Œ์ธ ํ–‰์„ ์ถœ๋ ฅ$ SELECT * FROM product WHERE NOT ๊ฐ€๊ฒฉ = 5000$ SELECT * FROM product WHERE ๊ฐ€๊ฒฉ !=..

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[DB] MySQL ๋ฐ์ดํ„ฐ ์กฐ์ž‘(SQL SELECT, ORDER BY) (3)

๋ฐ์ดํ„ฐ ์กฐ์ž‘SQL ํŽธ์ง‘์€ Tabel์—์„œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.  ๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. SQL์กฐํšŒ- SELECT ์ปฌ๋Ÿผ๋ช… FROM ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค.ํ…Œ์ด๋ธ”- SELECT ์ปฌ๋Ÿผ๋ช… FROM ํ…Œ์ด๋ธ”- SELECT ์ปฌ๋Ÿผ๋ช…1,์ปฌ๋Ÿผ๋ช…2 FROM ํ…Œ์ด๋ธ” ์ •๋ ฌ- ์˜ค๋ฆ„์ฐจ์ˆœ: SELECT ์ปฌ๋Ÿผ๋ช… FROM ORDER BY ์ปฌ๋Ÿผ๋ช… ASC- ๋‚ด๋ฆผ์ฐจ์ˆœ: SELECT ์ปฌ๋Ÿผ๋ช… FROM ORDER BY ์ปฌ๋Ÿผ๋ช… DESC- ์˜ค๋ฆ„์ฐจ์ˆœํ›„ ๊ทธ ์•ˆ์—์„œ ๋‚ด๋ฆผ์ฐจ์ˆœ: SELECT ์ปฌ๋Ÿผ๋ช… FROM ORDER BY ์ปฌ๋Ÿผ๋ช…1 ASC, ์ปฌ๋Ÿผ๋ช…2 DESC  ๋Œ€์†Œ๋ฌธ์ž ์„ค์ •์ด๊ฑด ๋ฝ€๋‚˜์“ฐ

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[DB] SQL&Database ๋๋‚ด๊ธฐ - MySQL ํ…Œ์ด๋ธ” ๋งŒ๋“ค๊ธฐ (2)

DBeaver - MySQL ๋กœ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.๊ฐ„๋‹จ ์†Œ๊ฐœDatabase๋Š” ํด๋”๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋˜๊ณ , Table์€ ํŒŒ์ผ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.ํ…Œ์ด๋ธ”์„ ๋งŒ๋“ค๊ณ , ์ปฌ๋Ÿผ์„ ๋งŒ๋“ค๊ณ , ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  row๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋•Œ Data Type์„ ์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค(Oracle, Postgresql ๋“ฑ)๋งˆ๋‹ค Data Type ์ด๋ฆ„์ด ๋‹ค๋ฅด๋‹ˆ, ์ฃผ์˜ํ•˜์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.  Data Type ์ข…๋ฅ˜(MySQL ๊ธฐ์ค€)

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[DB] SQL&Database ๋๋‚ด๊ธฐ - DBeaver ์„ค์น˜ ๋ฐ MySQL ์—ฐ๋™ with Mac (1)

MySQL ์„ค์น˜์ฐธ๊ณ : 2024.07.02 - [๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Modeling & SQL] - [DB] Mac์— MySQL ์„ค์น˜ (Community Server, WorkBench) #0$ brew install mysql@8.3$ open ~/.zshrc  - ๋„ฃ๊ธฐ: export PATH="$PATH:/usr/local/mysql/bin:/" $ mysql -u root -p  DBeaver ์„ค์น˜https://dbeaver.io/download/ Download | DBeaver CommunityDownload DBeaver Community 24.3 Released on December 2nd 2024 (Milestones). It is free and open source (..

๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database

[RDBMS] MySQL ํ„ฐ๋ฏธ๋„๋กœ ์ ‘์†ํ•˜๊ธฐ, ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ

ํ„ฐ๋ฏธ๋„๋กœ MySQL ์ ‘์†์„ค์น˜ ๊ฒฝ๋กœ๋กœ ์ด๋™ํ•˜๊ธฐ$ cd /usr/local/mysql/binMySQL root๋กœ ์ ‘์†ํ•˜๊ธฐ$ ./mysql -u root -p๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅํ•˜๊ณ  enter๋ฅผ ๋ˆ„๋ฅด๋ฉด mysql์— ์ ‘์†๋œ ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.  MySQL ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ์œ„ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ MySQL์— ์ ‘์†ํ–ˆ๋‹ค๋ฉด ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.โ€ป ์‚ฌ์šฉ์ž ์ด๋ฆ„์„ root๋กœ ๊ฐ€์ •ํ–ˆ์ง€๋งŒ, ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž ์ด๋ฆ„์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด root ๋ถ€๋ถ„์„ ํ•ด๋‹น ์‚ฌ์šฉ์ž ์ด๋ฆ„์œผ๋กœ ๋ฐ”๊พธ์–ด์ฃผ์„ธ์š”. $ ALTER USER 'root'@'localhost' IDENTIFIED BY '์ƒˆ๋กœ์šด_๋น„๋ฐ€๋ฒˆํ˜ธ';$ FLUSH PRIVILEGES; ์ดํ›„ MySQL์„ ๋‚˜๊ฐ‘๋‹ˆ๋‹ค.$ exit  ๋‹ค์‹œ MySQL๋กœ ์ ‘์†ํ•˜๊ณ , ๋ณ€๊ฒฝํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ํ™•์ธ..

SOIT
'๐Ÿ“ Back-end & ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป/Database' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก