Introduction
As we know, View is just a group of SQL statement which holds the data from one or more than one table. It is also called virtual table. So far, we know that View can contain rows and columns only, but View is different in Snowflake. In Snowflake, there are two types of Views.
- Non-Materialized view, also referred to as simply View
- Materialize View
We can also create a secure view by just adding secure keywork while creating Non-Materialized or Materialized View.
In this article, we are working with Non-Materialized View, and you will learn about creating Views to populate json data from one and more than one table. This real time scenario we are mostly using when we use View as API. I have also implemented the stored procedure in Snowflake to achieve the real-time scenario.
You can have a look at the article.
To work on Views, I have three problem statements here,
- Create View which will return table data in the form of rows and columns.
- Create View which will return the data in Json format
- Create View which will return the data from two tables.
As we know that the snowflake query will be executed under the context and Context will have four major things like Role, warehouse, database, and schema, I have already created warehouse, database, and schema. In our scenario, I will be using the following context,
- Role-sysadmin
- Warehouse-compute_wh
- Database-employeemanagement
- Schema-EM
Let us set up the required table first.
Step 1
Set up the context. Execute the following query to set up the context.
- use role sysadmin;
- use warehouse compute_wh;
- use database employeeManagement;
- use schema EM;
Step 2
Create a table called employee. Execute the below query.
- create or replace table employee(emp_id int, emp_name varchar,emp_address varchar);
Step 3
Insert the record into employee table
- insert into employee values(1,'Nitesh','Hyderabad');
- insert into employee values(2,'Sam','Hyderabad');
- insert into employee values(3,'Kam','Pune');
Step 4
Create employee_skill table. Perform the below query
- create or replace table employee_skill(
- skill_id number,
- emp_id number,
- skill_name varchar(50),
- skill_level varchar(50)
- );
Step 5
Insert a few records. Execute the below query.
- insert into employee_skill values(1,1,'C#','Advance');
- insert into employee_skill values(2,1,'Python','Basic');
- insert into employee_skill values(3,1,'SQL','Intermediate');
- insert into employee_skill values(1,2,'C#','Advance');
Please check the inserted data by running the select command
Step 6
Execute the below query to verify the data
- Select * from employee;

Step 7
Execute the below query to verify the data
- Select * from employee_skill;

Now, we have set up all the requirements. Let’s go ahead and work on the problem statement.
Scenario 1
Create View which will return table data in the form of rows and columns.
Solution
This is the normal scenario, where we create a view to populate data in the form of rows and columns.






Join the conversation! Your thoughts help the community grow.