SQL의 UPDATE문은 테이블의 데이터를 수정할 때 사용합니다.
기본 Syntax는 아래와 같습니다.
UPDATE 테이블명
SET 열 = '변경할값'
WHERE 조건;
위 데이터는 가상의 데이터로 10명의 이름, 나이, 거주 도시로 구성되어 있습니다.
proc sql;
UPDATE work.import
SET city = 'chef'
WHERE name = '김철';
select * from work.import;
WORK.IMPORT 데이터 중 NAME이 '김철'일 경우, 거주 도시를 'CHEF'로 수정합니다.
■ Null 값 update
위 데이터는 10명의 가상 데이터로 값이 없는 데이터가 있다.
proc sql;
update work.import3
set age = 999
where name is null;
select * from work.import3;
순서는 update > where > set 순이다.
update로 데이터를 수정해야할 테이블을 찾고, where 조건절로 name 변수의 값이 null 인 값을 찾아, age 변수를 999로 수정한다.
■ Is not Null Update
proc sql;
update work.import3
set city = 'newyork'
where city is not null;
select * from work.import3;
work.import3 데이터를 NULL 값이 아닌 값을 CITY 변수에 Newyork 로 수정하였다.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!