[MySQL] START TRANSACTION, COMMIT, and ROLLBACK Statements
참고
MySQL Documentation 13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements
설명
- 트랜잭션을 컨트롤하는데 사용
syntax
read moreSTART TRANSACTION [transaction_characteristic [, transaction_characteristic] ...] transaction_characteristic: { WITH CONSISTENT SNAPSHOT | READ WRITE | READ ONLY } BEGIN [WORK] COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE …
[MySQL] Statement Labels
참고
MySQL Documentation 13.6.2 Statement Labels
설명
- BEGIN ... END 블록의 고유한 이름으로 사용
syntax
read more[begin_label:] BEGIN [statement_list] END [end_label] [begin_label:] LOOP statement_list END LOOP [end_label] [begin_label:] REPEAT statement_list UNTIL search_condition END REPEAT [end_label] [begin_label:] WHILE search_condition DO statement_list …
[MySQL] STORED ROUTINE
A stored routine is either a procedure or a function. A procedure is invoked using a CALL statement and can only pass back values using output variables. A function can be called from inside a statement just like any other function and can return a scalar value.
read more[MySQL] 순서 매기기
순서 매기기
read moreSELECT @rownum:=@rownum+1 AS no, t.id, t.name FROM tree t WHERE (@rownum:=0)=0 AND t.`type` = 10 AND t.depth = 2 AND t.parent = 76 ORDER BY t.id ;
[MySQL] 순위함수
요약
목록 설명 ROW_NUMBER() 동등 순위를 인식하지 않고 매번증가되는 번호를 출력 DENSE_RANK() 순위 값 중 동등 순위 번호는 같게 나오고 그 다음 순 … [MySQL] 숫자함수
ABS
- 절대값 반환
SELECT ABS(-10) => 10
CEIL
- 올림
SELECT CEIL(1.3) => 2 SELECT CEIL(-1.3) => -1
FLOOR
- 내림
SELECT FLOOR(1.7) => 1 SELECT FLOOR(-1.7) => -2
MOD
- 나눠서 나머지 값 반환
read moreSELECT MOD(23, 10 …
[MySQL] 특정 값 중복되는 튜플만 뽑기
테이블
Person 테이블
id email 1 a@b.com 2 c@d.com 3 a@b.com 문제
- 중복되는 email만 뽑으시오
답
SELECT p.email AS email FROM Person p GROUP BY p.email HAVING COUNT(*) > 1 ;
스키 …
read more[MySQL] 특정 기간에만 존재하는 데이터 뽑기
테이블과 결과
read moreInput: Product table: +------------+--------------+------------+ | product_id | product_name | unit_price | +------------+--------------+------------+ | 1 | S8 | 1000 | | 2 | G4 | 800 | | 3 | iPhone | 1400 | +------------+--------------+------------+ Sales table: +-----------+------------+----------+------------+----------+-------+ | seller_id | product_id | buyer_id | sale_date | quantity | price | +-----------+------------+----------+------------+----------+-------+ | 1 | 1 | 1 | 2019-01-21 | 2 | 2000 | | 1 | 2 | 2 | 2019-02-17 | 1 | 800 | | 2 | 2 | 3 | 2019-06 …
[MySQL] 트랜잭션
트랜잭션
- SHOW VARIABLES LIKE '%COMMIT%'
- 현재 커밋과 관련된 설정정보 확인
- START TRANSACTION
- COMMIT
- ROLLBACK
SHOW VARIABLES LIKE '%COMMIT%' autocommit ON <- 여기 binlog_group_commit_sync_delay 0 binlog_group_commit_sync_no_delay_count 0 binlog_order_commits ON innodb_api_bk_commit_interval 5 innodb_commit_concurrency 0 innodb_flush_log_at_trx_commit 1 original_commit_timestamp 36028797018963968
read moreSTART TRANSACTION …