본문으로 건너뛰기
번역된 페이지

이 페이지는 AI의 도움을 받아 영어에서 번역되었습니다. 두 내용이 다를 경우 영어 버전을 기준으로 합니다.

REPLACE

리소스의 모든 필드를 업데이트합니다(put 작업과 동일).

참고 항목:
[ StackQL 리소스 계층 구조 ] [ UPDATE ]


구문​

replaceStatement::=

REPLACEmultipartIdentifierSETfullFieldAssignment','fullFieldAssignmentWHEREexpression'AND''OR'expression';'

 
 

REPLACE [ /*+ AWAIT */ ] <multipartIdentifier>
SET field_name = value [, field_name = value ...]
[ WHERE condition ];

예제​

기본 REPLACE 문​

REPLACE 문을 실행하여 GitHub 리포지토리의 토픽을 모두 교체합니다.

-- Replace all of the topics on a GitHub repository
REPLACE github.repos.topics
SET data__names = '["sql", "cloud-infrastructure"]'
WHERE owner = 'my-org'
AND repo = 'my-repo';

REPLACE 문(블로킹)​

REPLACE 문을 실행하여 Compute Engine 방화벽 규칙을 교체합니다. 이 호출은 블로킹(동기) 호출입니다.

-- Synchronous update of a google firewall
REPLACE /*+ AWAIT */ google.compute.firewalls
SET
data__name = 'test-fw',
data__network = 'https://www.googleapis.com/compute/v1/projects/stackql-demo/global/networks/my-vpc',
data__direction = 'INGRESS',
data__sourceRanges = '["0.0.0.0/0"]',
data__allowed = '[{"IPProtocol": "tcp", "ports": ["22"]}, {"IPProtocol": "tcp", "ports": ["6443"]},{"IPProtocol": "icmp"}]'
WHERE firewall = 'test-fw'
AND project = 'stackql-demo';

JSON 함수를 사용하는 REPLACE 문​

JSON 함수로 값을 구성하는 REPLACE 문을 실행합니다. 열을 읽지 않는 함수는 요청을 보내기 전에 평가됩니다. SET 값은 교체 대상 행을 읽을 수 없으므로, 기존 값의 일부를 변경하려면 먼저 SELECT 문으로 값을 읽은 다음 수정한 값을 설정하세요.

-- Replace the topics on a GitHub repository with a list built by json_array
REPLACE github.repos.topics
SET data__names = json_array('sql', 'cloud-infrastructure', 'infrastructure-as-code')
WHERE owner = 'my-org'
AND repo = 'my-repo';