반응형
SQL Server 2005 이전에는 Timestamp로 제공되었으나 이후 ROWVERSION으로 변경됨.
-- 테이블 생성 CREATE TABLE Employee ( EmployeeID INT PRIMARY KEY, FirstName NVARCHAR(50), LastName NVARCHAR(50), HireDate DATETIME, RowVersionColumn ROWVERSION ); -- 데이터 입력 INSERT INTO Employee (EmployeeID, FirstName, LastName, HireDate) VALUES (1, 'John', 'Doe', '2024-01-15'); INSERT INTO Employee (EmployeeID, FirstName, LastName, HireDate) VALUES (2, 'Jane', 'Smith', '2024-02-20'); INSERT INTO Employee (EmployeeID, FirstName, LastName, HireDate) VALUES (3, 'Emily', 'Jones', '2024-03-25'); -- 데이터 조회 SELECT * FROM Employee; /* EmployeeID FirstName LastName HireDate RowVersionColumn 1 John Doe 2024-01-15 00:00:00.000 0x00000000000008DF 2 Jane Smith 2024-02-20 00:00:00.000 0x00000000000008E0 3 Emily Jones 2024-03-25 00:00:00.000 0x00000000000008E1 */ -- 데이터 수정 UPDATE Employee SET LastName = 'Doe-Smith' WHERE EmployeeID = 2; -- ROWVERSION 확인 SELECT * FROM Employee WHERE EmployeeID = 2; /* EmployeeID FirstName LastName HireDate RowVersionColumn 2 Jane Doe-Smith 2024-02-20 00:00:00.000 0x00000000000008E2 */ |
반응형