Lock-Free Reservation #1
·
Oracle/SQL
Oracle 23c에 Lock-Free Reservation 기능이 추가되었습니다. 해당 기능은 로우 락 대신 Reservation Journal 테이블(이후 저널 테이블)을 통해 잔고, 재고, 예약 가능 좌석 수 등을 갱신하는 트랜잭션의 동시성을 향상시킵니다.Lock-Free Reservations enables concurrent transactions to proceed without being blocked on updates of heavily updated rows. Lock-Free reservations are held on the rows instead of locking them. Lock-Free Reservations verifies if the updates can succeed ..
Table Value Constructor
·
Oracle/SQL
개요Oracle 23c에 Table Value Constructor(이후 TVC) 기능이 추가되었습니다.The database's SQL engine now supports a VALUES clause for many types of statements. This new clause allows for materializing rows of data on the fly by specifying them using the new syntax without relying on existing tables. Oracle supports the VALUES clause for the SELECT, INSERT, and MERGE statements. The introduction of the new VALUES..
BOOLEAN 타입
·
Oracle/SQL
Oracle 23c부터 SQL 문에 BOOLEAN 타입을 사용할 수 있습니다.Oracle Database now supports the ISO SQL standard-compliant BOOLEAN data type. This enables you to store TRUE and FALSE values in tables and use BOOLEAN expressions in SQL statements. The BOOLEAN data type standardizes the storage of Yes and No values and makes it easier to migrate to Oracle Database. 테스트를 위해 아래와 같이 c2 칼럼이 BOOLEAN 타입인 테이블을 생성하겠습니다.-- 1-..
FROM 절 미사용 SELECT 문
·
Oracle/SQL
Oracle 23c부터 FROM 절을 사용하지 않은 SELECT 문을 사용할 수 있습니다.You can now run SELECT expression-only queries without a FROM clause. This new feature improves SQL code portability and ease of use for developers. 아래 SELECT 문은 FROM 절을 사용하지 않습니다.  23.2 버전은 결과가 반환되지만, 19.3 버전은 에러가 발생합니다. 1-1번 쿼리의 실행 계획에서 내부적으로 DUAL 테이블이 사용되는 것을 알 수 있습니다.-- 1-1: 23.2SELECT 1 AS c1;C1-- 11개의 행이 선택되었습니다.----------------------------..
GROUP BY 절과 HAVING 절 표현식 개선
·
Oracle/SQL
개요Oracle 23c부터 GROUP BY 절과 HAVING 절에 칼럼 앨리어스를 사용하거나, GROUP BY 절에 위치 표현식을 사용할 수 있습니다.You can now use column alias or SELECT item position in GROUP BY, GROUP BY CUBE, GROUP BY ROLLUP, and GROUP BY GROUPING SETS clauses. Additionally, the HAVING clause supports column aliases. These enhancements make it easier to write GROUP BY and HAVING clauses. It can make SQL queries much more readable and main..
날짜 값에 CEIL, FLOOR 함수 사용
·
Oracle/SQL
Oracle 23c부터 DATE, TIMESTAMP, INTERVAL 등의 날짜 값에 CEIL, FLOOR 함수를 사용할 수 있습니다.You can now pass DATE, TIMESTAMP, and INTERVAL values to the CEIL and FLOOR functions. These functions include an optional second argument to specify a rounding unit. You can also pass INTERVAL values to ROUND and TRUNC functions. These functions make it easy to find the upper and lower bounds for date and time values for..
INTERVAL 값 집계
·
Oracle/SQL
Oracle 23c부터 INTERVAL 값에 SUM 함수와 AVG 함수를 사용할 수 있습니다.You can pass INTERVAL datatypes to the SUM and AVG aggregate and analytic functions. This enhancement makes it easier for developers to calculate totals and averages over INTERVAL values. 테스트를 위해 아래와 같이 테이블을 생성하겠습니다.-- 1DROP TABLE t1 PURGE;CREATE TABLE t1 (c1 INTERVAL DAY TO SECOND, c2 INTERVAL DAY TO SECOND);INSERT INTO t1 VALUES (INTERVAL '1'..
IF [NOT] EXISTS 절
·
Oracle/SQL
Oracle 23c부터 일부 DDL 문에 IF [NOT] EXISTS 절을 사용할 수 있습니다.DDL object creation, modification, and deletion now support the IF EXISTS and IF NOT EXISTS syntax modifiers. This enables you to control whether an error should be raised if a given object exists or does not exist. The IF [NOT] EXISTS syntax can simplify error handling in scripts and by applications. 아래와 같이 DROP TABLE, CREATE TABLE, ALTER TAB..
UPDATE 문, DELETE 문에 대한 직접 조인
·
Oracle/SQL
Oracle 23c부터 UPDATE 문과 DELETE 문에 대한 직접 조인이 가능해졌습니다.Join the target table in UPDATE and DELETE statements to other tables using the FROM clause. These other tables can limit the rows changed or be the source of new values. Direct joins make it easier to write SQL to change and delete data. 테스트를 위해 아래와 같이 테이블을 생성하겠습니다.-- 1DROP TABLE t1 PURGE;DROP TABLE t2 PURGE;CREATE TABLE t1 (c1, c2) AS SELECT R..
ORA-01779 에러
·
Oracle/SQL
Oracle 21c부터 Updatable Join View에 대한 ORA-01779 에러가 사라진 것으로 보입니다. 참고로 이 에러와 관련된 BYPASS_UJVC 힌트는 11.1 버전에서 deprecate되었습니다.Starting with Oracle Database Release 21c, it is not mandatory for all updatable columns in a join view to map to columns of a key-preserved table. When updating a join view, ensure that the UPDATE operation is deterministic. Note that this does not cause any impact on update p..
무한소수의 집계 순서에 따른 결과 값
·
Oracle/SQL
무한소수는 집계 순서에 따라 결과 값이 달라질 수 있습니다. 이로 인해 데이터 마이그레이션 이후 데이터 조회 순서가 달라져 쿼리의 결과 값이 달라질 수 있습니다. 테스트를 위해 아래의 테이블을 생성하겠습니다.-- 1DROP TABLE t1 PURGE;CREATE TABLE t1 AS SELECT ROWNUM * 100 AS c1 FROM XMLTABLE ('1 to 12'); 아래 쿼리의 c2 열은 c1 칼럼을 12로 나눠 일부 값이 무한소수로 반환됩니다.-- 2SELECT c1, c1 / 12 AS c2 FROM t1; C1 C2---- ---------- 100 8.33333333 -- ! 200 16.6666667 -- ! 300 25 400 33.3333333 -- ..
FOR UPDATE SKIP LOCKED 절 사용 방법
·
Oracle/SQL
FOR UPDATE SKIP LOCKED 절은 주로 다중 소비자 큐(multi-consumer queue)을 구현하기 위해 사용됩니다. 테스트를 위해 아래와 같이 테이블을 생성하겠습니다. 선착순으로 쿠폰을 발생하는 업무를 가정하여 c1 칼럼은 쿠폰번호, c2 칼럼은 발생여부 값을 저장합니다. -- 1 DROP TABLE t1 PURGE; CREATE TABLE t1 AS SELECT ROWNUM AS c1, 'N' AS c2 FROM XMLTABLE ('1 to 10'); CREATE INDEX t1_x1 ON t1 (c2, c1); 1번 세션에서 아래 쿼리를 실행하면 c1이 1인 행에 락이 설정됩니다. -- 2: S1 SELECT * FROM t1 WHERE c1 >= 1 AND c2 = 'N' AND..