Views in SQL is nothing but the logical table created from one or more tables. We can use the views to fetch the columns from one or more different tables at a time. In real life specifically views are used in Reporting purpose. To create a report we need data from different tables and need to show it on a single dashboard so we are using the views to fetch the data from different tables. View can contain all rows from the table or selected rows from the table. I would like to give more information about difference between simple view and complex view in detail.
CLICK HERE TO GET INFORMATION ON MATERIALIZED VIEW……..
View is nothing but virtual table in sql which will fetch data from one or more physical tables
There are 2 types of views in SQL:
1.Simple View-Simple view is view created on single table
2.Complex View-Complex view is view created on more than 1 tables
- Simple View:
When user wants data or some columns from same table then simple view is used. For an example if there is employee table which has Employee_num,Employee_name,salary columnns and we just need to see Employee_num,Employee_name then user can create a simple view.
Employee_num | Employee_name | Department | Salary |
1 | Amit | OBIEE | 680000 |
2 | Rohan | OBIEE | 550000 |
3 | Rohit | OBIEE | 430000 |
We want to restrict data from the above table and show only Employee_Num and Employee_name then we will use the view.
Syntax:
Create view Viewname
as Select column_name1,Coumn_name2 from tablename.
Example:
Create view V_Employee
as Select Employee_num,Employee_name from Employee;
You can access the view using Select statement of SQL:
select * from V_Employee;
Output:
Employee_num | Employee_name |
1 | Amit |
2 | Rohan |
3 | Rohit |
- Complex View:
Complex view is created on using more than one tables. When user wants to retrieve data from more than 1 table then we have to use complex views. To create complex view there should be relation between 2 tables else cartesian product will come by joining 2 tables. There should be some joining conditions, some filters needs to be considered while creating complex views.
Suppose there are 2 tables:
1.Employee tables:-Employee_name,Employee_num,Department_code columns
2.Department:-Department_code,Deptartment_name columns
We need to create view where we want to show the associated department to employee.Here We need to use complex join.
Create view V_EMP_DEPT
as Select e.Employee_name,d.Department_name
from Employee e,Department d
where e.Department_code=d.Department_code;
If you have any issues regarding SQL Views or If you want notes in PDF format comment below section.
Difference between simple view and complex view in tabular format :
Simple View | Complex View |
Simple view is the view which has been created by only one table. | Complex view is the view where we require to join multiple tables together for specified result. |
We can not use group functions in simple views | We can able to use group functions |
You can perform multiple DML operations using simple view | You can not perform DML operations using complex view |
It does contain data from only one table | It does contain data from multiple tables |
We can not be able to use group by clause in simple view as grouping is not allowed | We can use group by clause in complex view |
We can not be able to use pseudo columns like rownum and distinct keyword | We can use the pseudo columns and rownum |
Example :
Create view V_simple_view As select Empno,Empname from Employee; |
Example :
Create view V_Complex_view As Select e.emp_no,d.dept_no,e.emp_name from Employee e ,Department d where e.dept_no=e.dept_no; |
I hope you are clear with difference between simple view and complex view with examples. If you like this article or if you have any issues with the same kindly comment in comments section.
CLICK HERE TO GET 20 MOST IMPORTANT SQL INTERVIEW QUESTIONS
HOME
Need PDF of this Topic
Sure Deepmala..Kindly check your mailbox..
pls share pdf format.
sure savi!!!
Need PDF doc
sent you interview questions
Hi, Please provide me the pdf doc.
Thank you.
Sure Mohan ..I will send you interview questions..
send to me also
hi Amit,
can u please share me the complete oracle notes with simple understanding and example, not as complex as other tutorials
I have sent you the notes and interview questions on mail.
Please sir send me also
Sure Priyanka…
Check your inbox.
please sir send me the complete oracle notes with simple understanding and example, and also interview questions
please send me pdf durgesh2872@gmail.com,
great job sirg
Hey Durgesh,
Thanks!! I have sent you interview questions on your mail id.
Regards,
Amit S
Hi,
Its neatly explained. Could you please send the interview related questions of SQL to my email id : ajitsonu18@gmail.com
Thanks for the help!
Regards,
Ajit Kumar
Sure Ajit!!! I am sending you interview questions..
Hi Amit,
Could you send all topic in PDF format to my email id. Thanks in Advance!!
sure sheshagiri!!
can u please share me the complete SQL,Unix notes with simple understanding and example, not as complex as other tutorials
Sure Ganesh!!!
Hi Amit,
Thanks! It is easy to understand.
Please share sql documents and interview questions for experienced professional.
—
Regards
SKG
sent you SQL documents!!
Department code is the common column in both the tabels.
Then how can you write
e.department_no =d.department_no
As department_no is not a column in any of the tables. I
Hello A S,
Thanks for catching up the typo error.I have changed the typographic error and corrected it!!
Regards and thanks,
Amit S
Pls provide pdf on sql for advance diploma in computer based accounting if u can…
Sure I have sent you interview questions on your mail id!!
hi amit,
can u pl send me the interview questions to my mail id
Sure Sarath..
Kindly check your inbox
can you please send sql notes to my mailid
mailed you interview questions..
Hi Amit,
Could you please provide the SQL ,Plsql notes.
And also performance tuning related notes.
Thanks you
sure balaji sent you interview questions
sure sent you interview questions..
Hi Amit,
This is soumya ,could you please share me the complex SQL queries with its explanations and perfermance tuning notes with simple understanding and examples
Hi,
Could you please send me the notes in pdf format.
Thanks in advance
hi pritilipi,
I sent you Pdf format notes on your specified mail id.
Regards,
Amit S
Can you please send me PDF doc on view to know it briefly
please provide the complex queries and complex questions of each topic of sql, if you have PDF regarding this please provide.
Email Id- kkalpanagupta33@gmail.com
Regards
Kalpana Gupta
Sure Kalpana..I have sent you some important complex sql Queries interview questions.
Dear Amit i am waiting for you mail
Sorry Sentil for late..I have sent you interview questions on your mail id.
Hi,
Could you pls send me advanced sql and performance tuning notes.
Thanks in advance.
Hi Amit,
Can you send me a pdf which covers all topics interview questions oracle for both fresher and experienced level
jastigouthami39@gmail.com
Hi Amit,
Can u tell me some real time examples for creating a view(say for example motor insurance domain)..and some performance tuning methods..
Thanks in advance
Hi,
Could you please send me the notes in pdf format.
Thanks in advance
Hello Sir,
Can you please send the interview questions for sql .
email id : priya.161989@gmail.com
can u please share the interview questions and notes
good work amit !
hi amit
can u please share me the details of creating indexes, Views, complex Stored Procedures, user defined functions, derived tables, Temporary Tables, Sub query, CTE and Triggers.
Hi Amit,
Good work, as always.
Mah sincere gratitude to you.
Please send me the notes and interview questions
Hi Amit, the content you explained is so easy to understand. You made that look easy. Thanks for that. Can you please send the pdf formats for VIEWS and STORED PROCEDURES (IF POSSIBLE).
Thank you
plz send me the plsql material and oracle interview questions.
Could you please send the interview related questions of SQL ,PL/SQL.
Good explanation!
I have interview coming up for a BI developer, can you share anything that can help?
Thanks
please sir send me the complete oracle notes with simple understanding and example, and also interview questions
Hi Amit,
can u please share me the complete oracle notes with simple understanding and example, not as complex as other tutorials, please also share the contect for view and materialized , Non-materialized view.
Email : rv50611@gmail.com
Thanks,
Rahul
Hi Amit, Can you please share me Materialized view documents where it is used real time .