How to Use UPDATE Statements for Data Management using snowflake

Опубликовано: 15 Март 2026
на канале: Data World Solution
555
8

Join us as we delve into the powerful capabilities of Snowflake's UPDATE statements, enabling you to efficiently manage and modify data within your Snowflake data warehouse. Whether you're a seasoned data professional or just starting your journey, this comprehensive tutorial provides step-by-step guidance to harness the full potential of Snowflake's data manipulation features. Learn practical tips, best practices, and real-world examples to streamline your data management processes and maximize the value of your Snowflake environment. Watch now and unlock new levels of data agility with Snowflake's UPDATE statements.


------------
SQL
-------------------------------------

-- update statement


-- modify existing value in a table
/*
syntax:

update table_name
set column_name = value [,column = value , ...]
[where condition];

*/


-- use the primary key column in the where clause to identify a single row for update.
--using other columns might accidentally update multiple row




CREATE OR REPLACE TABLE employees (
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50),
salary int,
department VARCHAR(50),
email VARCHAR(100)
);



INSERT INTO employees (employee_id, first_name, last_name, salary, department, email)
VALUES
(1, 'John', 'Doe', 60000, 'HR', '[email protected]'),
(2, 'Jane', 'Smith', 55000, 'Marketing', '[email protected]'),
(3, 'Michael', 'Smith', 65000, 'Engineering', '[email protected]'),
(4, 'Emily', 'Brown', 58000, 'Finance', '[email protected]'),
(5, 'David', 'Wilson', 62000, 'HR', '[email protected]'),
(6, 'Sarah', 'Taylor', 57000, 'Marketing', '[email protected]'),
(7, 'Matthew', 'Anderson', 68000, 'Engineering', '[email protected]'),
(8, 'Jessica', 'Martinez', 59000, 'Finance', '[email protected]'),
(9, 'Christopher', 'Hernandez', 63000, 'HR', '[email protected]'),
(10, 'Amanda', 'Robinson', 60000, 'Marketing', '[email protected]');

SELECT * FROM employees ;

UPDATE employees
SET department = 'Marketing'
WHERE employee_id = 1;

SELECT * FROM employees;

UPDATE employees
SET department = 'Marketing'
WHERE last_name = 'Smith';

SELECT * FROM employees;



-- You can change more than one column at same time.

UPDATE employees
SET SALARY =50000 , DEPARTMENT ='Finance'
WHERE EMPLOYEE_ID=5;



SELECT * FROM employees;



-- in update , you can set the column to null value


UPDATE employees
SET DEPARTMENT=NULL
WHERE EMPLOYEE_ID=3;


SELECT * FROM employees;

-- Subquery
-- Make Employee id 1's salary the same as Employee id 2's salary

UPDATE employees
SET salary=(select salary from employees where EMPLOYEE_ID=2)
WHERE EMPLOYEE_ID=1;


SELECT * FROM employees;


-- If you don't specify a condition, the update will affect all the rows in the table

UPDATE employees
SET SALARY =24100;

SELECT * FROM employees;


----------------------------------

#Snowflake #DataManagement #UPDATEStatement #DataManipulation #DataWarehousing #DataAgility #SQL #Tutorial #DataProfessionals #TechTutorial #DataAnalysis #DataScience #CloudComputing