In this blog, you will learn all about how to create a table in Snowflake and insert data into it.
To create a table in Snowflake, follow the steps below
Step-1: Add a new
Step-2: To select the
schema in which you want to
create a table, write the following SQL query and execute it.
Run the following SQL queries one by one.
USE ROLE SYSADMIN; USE DATABASE DEVDB; USE SCHEMA PUBLIC;
Step-3: Now, write a
CREATE TABLE statement to create a table with the following syntax:
CREATE TABLE table_name ( column1_name data_type, column2_name data_type, ... );
Example: Create an
Run the SQL statement below.
CREATE TABLE employees ( emp_id INT AUTOINCREMENT PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), salary DECIMAL(10, 2) );
Insert data into Table
You can insert data into the newly created table using the
INSERT INTO statement. Here’s an example:
INSERT INTO employees (first_name, last_name, salary) VALUES ('Sandeep', 'Raturi', 50000.00), ('David', 'Keyes', 60000.00), ('Mark', 'Smith', 55000.00);
Verify Data Insertion:
To verify that the data was inserted successfully, you can query the table using a
Drop Table in Snowflake
To drop (delete) a table in Snowflake, you can use the
DROP TABLE statement.
DROP TABLE employees;
View Table Definition in Snowflake
Under the Data tab, select Databases and choose Table.
Thank you for reading this post, and I hope you enjoyed it!