Open In App

Difference Between View and Table

Improve
Improve
Like Article
Like
Save
Share
Report

View and Table both are integral parts of a relational database, and both terms are used interchangeably. The view is a result of an SQL query and it is a virtual table, whereas a Table is formed up of rows and columns that store the information of any object and be used to retrieve that data whenever required. In this article, we are going to discuss the difference between View and Table. 

View: 

A view contains no data of its own but it is like a ‘window’ through which data from tables can be viewed or changed.  A view is a query of one or more tables that provides another way of presenting the information. In layman’s terms, a view is a “stored query “.  It is also called a derived table because it is derived from another table. Views do not actually store data rather they derive their data from tables on which they are based, referred to as the base table of the view. The view is stored as a SELECT statement in the data dictionary. Creating a view fulfills the requirement without storing a separate copy of the data because a view does not store any data of its own and always takes the data from a base table. as the data is taken from the base table, accurate and up-to-date information is required.

Syntax:

Create or Replace view <view name> as select column_list from <table_name>

Here,  <view name> is the name of the view, or Replace option recreates a view if it already exists. To create a view, a user must have the privilege to select from each and every base table and view referenced in the view.

Table:

In DBMS data is stored in the form of relations i.e. in the tables. A table is a database object which is used to store data in relational databases in the form of rows and columns. It actually stores the data in DBMS. It is also known as a base table.  A column in the database table represents the tables’ attributes and a row represents a single set of column values in the database table. Each column of the table has a column name and a data type associated with it. We can easily create and manipulate the data in the database. The table name must begin it contains letters, numerals, and special characters. The names of the tables owned by a given user must be unique. The table name must not be a SQL reserve word. The table name is not case-sensitive. The name must not be the same as the name of any other object in your schema. 

Syntax:

Create table <table_name>


(<column list> <data_type>);

Here, <table_name> is the name of the table, <column list> represents the number of columns in the list and a <data_type> represents the type of data stored in table. The datatype that can be used includes VARCHAR2, NUMBER, DATE, etc.

Difference between View and Table:

Following are the differences between the view and table.

Basis View Table
Definition A view is a database object that allows generating a logical subset of data from one or more tables. A table is a database object or an entity that stores the data of a database.
Dependency The view depends on the table. The table is an independent data object.
Database space The view is utilized database space when a query runs. The table utilized database space throughout its existence.
Manipulate data We can not add, update, or delete any data from a view. We can easily add, update, or delete any data from a table.
Recreate We can easily use replace option to recreate the view. We can only create or drop the table.
Aggregation of data Aggregate data in views. We can not aggregate data in tables.
table/view relationship The view contains complex multiple tables joins. In the table, we can maintain relationships using a primary and foreign key.

Last Updated : 02 Nov, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads