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에..
· 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를 자동으로 ..
· 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은 쉼표가 아닌 키워드를 사용하여 인수를 구분하는 ..
· 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 패턴은 다음과 같은 구문으로 사용될 수 있습니다..
· 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을 제외..
· 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' 태그의 글 목록