In this tutorial, learn how to modify existing tables in Snowflake by adding new columns using the ALTER TABLE command. Whether you're updating your database schema or enhancing your data model, this step-by-step guide will show you the process of adding columns seamlessly in Snowflake. Dive into practical examples and best practices to ensure smooth data management in your Snowflake environment.
#Snowflake #DataManagement #DatabaseSchema #DataModeling #SQL #ALTERTABLE #DatabaseAdministration #DataEngineering #DataWarehousing #CloudDataWarehouse #techtutorial
-----SQL QUERY--------------------------
-- ALTER TABLE / ADD COLUMN
CREATE OR REPLACE TABLE employees (
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50)
);
-- Insert sample data into the employees table
INSERT INTO employees (employee_id, first_name, last_name)
VALUES
(1001, 'John', 'Doe'),
(1002, 'Jane', 'Smith'),
(1003, 'Michael', 'Johnson'),
(1004, 'Emily', 'Brown');
SELECT * FROM employees;
ALTER TABLE employees
ADD COLUMN GENDER CHAR(1) ;
ALTER TABLE employees
ADD (GENDER1 CHAR(1)) ;
SELECT * FROM employees;
ALTER TABLE employees
ADD (department varchar default '00' not null );
ALTER TABLE employees
ADD (department varchar not null );
SELECT * FROM employees;
ALTER TABLE employees
ADD ( CREATED_DATE DATE , CREATED_BY varchar2(100) );
select * from employees;