[draw.io] sql๋ฌธ ๊ฐ€์ ธ์˜ค๊ธฐ
ยท
๐Ÿ› ๏ธ Tools
ERD ๊ณต์œ  ๋งˆ์Šคํ„ฐhttps://www.erdcloud.com/ ERDCloudDraw ERD with your team members. All states are shared in real time. And it's FREE. Database modeling tool.www.erdcloud.com ERDCloud๋ฅผ ์ด์šฉํ•˜๋ฉด ํ˜„์žฌ ์‚ฌ์šฉ๋˜๋Š” ์œ ๋ช… ํ”Œ๋žซํผ์˜ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๊ฐ„์ ‘์ ์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์‹ค์ œ๋กœ ์œ ํšจํ•œ ์ž‘์—…์ธ์ง€๋Š” ๋ชจ๋ฅด๋‚˜ ์˜คํ”ˆ์œผ๋กœ ๊ณต์œ ๋œ ERD ์†Œ์Šค๋“ค์ด ์ƒ๋‹นํžˆ ๋งŽ๋‹ค. ์ด๋ ‡๊ฒŒ ์ž‘์„ฑ๋œ ERD๋ฅผ draw.io๋กœ ๊ฐ€์ ธ์™€ ์ผ์„ ์ž๋™ํ™” ์‹œ์ผœ๋ณด์ž.  ์œ„์˜ ์˜ˆ์‹œ๋Š” ๋ฐฐ๋‹ฌ์˜ ๋ฏผ์กฑ ERD ์˜ˆ์‹œ์ด๋‹ค. ์œ ํšจํ•œ์ง€๋Š” ๋ชจ๋ฅด๋‚˜ ERD ํ…œํ”Œ๋ฆฟ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹๋‹ค. ์šฐ์ธกํ•˜๋‹จ์˜๋‚ด๋ณด๋‚ด๊ธฐ > SQL ๋‹ค์šด๋กœ๋“œ๋กœ sql ๋ฌธ์„ ๊ฐ€์ ธ์™€ ๋ฐ”๋กœ DB์—..
[MySQL] You have an error in your SQL syntax .. ๋„ˆ์˜ Query๋Š” ํ‹€๋ ธ์–ด,,
ยท
๐Ÿ›ข๏ธ Database
CASE 1) (24.02.10) 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'You and what army?"\nI guess they\'re talking about you and me\nBaby, nobody will l\' at line 23' python dedent์—์„œ backspace ์‚ฌ์šฉ ๋‚จ๋ฐœ๋กœ ์ œ๋Œ€๋กœ ๋œ query๊ฐ€ ์ˆ˜ํ–‰๋˜์ง€ ์•Š์•„ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ,, Python ํ˜น์€ ๋‹ค๋ฅธ ์–ธ์–ด๋“ค ๋Œ€๋ถ€๋ถ„ ๋“ค์—ฌ ์“ฐ๊ธฐ(indent)์— ๋ฏผ๊ฐํ•ด sqlparse ๋ชจ๋“ˆ๋กœ query์˜ ์ค„๋ฐ”๊ฟˆ upper case๋ฅผ ์ž๋™์œผ๋กœ ..
[SQL] LEFT, REPLACE, SUBSTRING
ยท
๐Ÿ›ข๏ธ Database
PostgreSQL ๋ฌธ๋ฒ• ์˜ˆ์ œ Table - Ticker information ๋”๋ณด๊ธฐ NOTE https://www.postgresql.org/docs/current/functions-string.html 9.4. String Functions and Operators 9.4. String Functions and Operators 9.4.1. format This section describes functions and operators for examining and manipulating string values. Strings in … www.postgresql.org ๋ฌธ๋ฒ•์— ์•ž์„œ PostgreSQL์— ์‚ฌ์šฉ ๋˜๋Š” ๋ฌธ์ž์—ด ํ•จ์ˆ˜์™€ ์—ฐ์‚ฐ์ž ์‚ฌ์šฉ์‹œ SQL์€ ์‰ผํ‘œ๊ฐ€ ์•„๋‹Œ ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ธ์ˆ˜๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š” ..
[SQL] LIKE
ยท
๐Ÿ›ข๏ธ Database
https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP 9.7. Pattern Matching 9.7. Pattern Matching 9.7.1. LIKE 9.7.2. SIMILAR TO Regular Expressions 9.7.3. POSIX Regular Expressions There are three separate approaches to pattern … www.postgresql.org [Postgre Document] 9.7.1. LIKE LIKE ์—ฐ์‚ฐ์ž๋Š” SQL ํ‘œ์ค€์— ๋”ฐ๋ผ ํŒจํ„ด์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฌธ์ž์—ด์„ ๋น„๊ตํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. LIKE ํŒจํ„ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ๋ฌธ์œผ๋กœ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค..
[SQL] Count ํ•จ์ˆ˜, Sequel vs SQL
ยท
๐Ÿ›ข๏ธ Database
Null ๊ฐ’์— ๋”ฐ๋ผ ๋ณ€ํ•˜๋Š” Count function ์˜ˆ์‹œ ํ…Œ์ด๋ธ” (table=account) Case 1) SELECT COUNT(1) FROM account; Result : 4; COUNT(1) : for i in row: row_count+=1; ๊ณผ ๊ฐ™์ด ์ „์ฒด row ์ˆ˜๋ฅผ ํ•˜๋‚˜ํ•˜๋‚˜ ๋”ํ•ด ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. COUNT(1) = COUNT(*) = total_row_count๋ผ๊ณ  ๋ด๋„ ๋ฌด๋ฐฉํ•˜๋‹ค. Case 2) SELECT COUNT(Name) FROM account; Result : 3 COUNT(Name) Name ์ปฌ๋Ÿผ์—์„œ Null์„ ์ œ์™ธํ•œ ์—ด์˜ ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. Case 3) SELECT COUNT(DISTINCT Name) FROM account; Result : 2 DISTINCT๋Š” Null์„ ์ œ์™ธ..
[Mysql] python executemany ์‚ฌ์šฉ์‹œ TypeError: not all arguments converted during string ...
ยท
๐Ÿ›ข๏ธ Database
cursor.executemany(sql, data)๋กœ ๋‹ค์ˆ˜์˜ ๋กœ์šฐ ๋ฐ์ดํ„ฐ๋ฅผ INSERT ํ•  ์ˆ˜ ์žˆ๋‹ค. sql : INSERT ์ฟผ๋ฆฌ ๋ฌธ์„ ๋„ฃ์œผ๋ฉด ๋œ๋‹ค. sql = """INSERT INTO TBL_NAME (COL1_NAME, COL2_NAME, COL3_NAME) VALUES(%s,%s,%s)""" data : sql ์ž…๋ ฅ ํŒŒ๋ผ๋ฏธํ„ฐ๋“ค์„ tuple๋กœ ๋งŒ๋“ค๊ณ  list๋กœ ๊ฐ์‹ธ์ฃผ๋ฉด ๋œ๋‹ค. data = [(parm1,parm2,parm3),(parm1,parm2,parm3),(parm1,parm2,parm3)....] [ERROR] TypeError: not all arguments converted during string sql๋ฌธ์—์„œ ON DUPLICATE KEY UPDATE ์‚ฌ์šฉ์‹œ ์ฃผ์˜ [์ž˜๋ชป๋œ ๋ฐฉ์‹] s..
๋‹คํ–ˆ๋‹ค
'SQL' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก