.NET FAQs Unleashed!
 
    



    


What is the difference between a Table, View and Synonym in SQL?

A Table is a repository of data, where in the table itself is a physical entity. The table resides physically in the database.

A View is not a part of the database's physical representation. It is precompiled, so that data retrieval behaves faster, and also provide a secure accessibility mechanism.

See code example below:

Create table T_EMPLOYEE
(Emp_Id integer primary key,
Name varchar2(50)
Skillset varchar2(200),
Salary number(12,2),
DOB datetime);

Say there is a scenario where Salary is not to be shown to a group of users, a View may be created to display allowable information:

Create view EMP_SOME_DETAILS
as
(Select Emp_Id, Name, Skillset, DOB
From T_EMPLOYEE);

The advantages of using a view are as follows:
- It may access data from a table, multiple tables, view, multiple views, or a combination of these
- A view connects to the data of its base table(s).
- Provides a secure mechanism of data accessibility

Synonym is alternate name assigned to a table, view, sequence or program unit.
- It may be used to shadow the original name and owner of the actual entity
- Extends the reach of tables, by allowing public access to the synonym

SQL Queries  SQL  Create Table  DDL, Create, Alter, Drop commands  DML, Select, Insert, Update, Delete  Create Database  ACID Rules  Dual Table  NULL  Join, Inner, Outer, Left, Right, Full, Cartesian, Natural, Equi  Table, View and a Synonym?  Execute  Function  Stored Procedure  Syntax Stored Proc  Stored Procedure Vs. Function




ShoutMix chat widget





Know Your Breath, Know Your Life!!!