What is the difference between database table and database view?
The database table has a physical existence in the database. A view is a virtual table, that is one that does not actually exist. View is made up of a query on one or many tables in a database.
In database theory, a view is the result set of a stored query on the data, which the database users can query just as they would in a persistent database collection object. This pre-established query command is kept in the database dictionary. Unlike ordinary base tables in a relational database, a view does not form part of the physical schema: as a result set, it is a virtual table computed or collated from data in the database, dynamically when access to that view is requested. Changes applied to the data in a relevantunderlying table are reflected in the data shown in subsequent invocations of the view. In some NoSQL databases, views are the only way to query data.
Views can provide advantages over tables:
- Views can represent a subset of the data contained in a table; consequently, a view can limit the degree of exposure of the underlying tables to the outer world: a given user may have permission to query the view, while denied access to the rest of the base table.
- Views can join and simplify multiple tables into a single virtual table
- Views can act as aggregated tables, where the database engine aggregates data (sum, average etc.) and presents the calculated results as part of the data
- Views can hide the complexity of data; for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table
- Views take very little space to store; the database contains only the definition of a view, not a copy of all the data which it presents
- Depending on the SQL engine used, views can provide extra security
Read-only vs. updatable views
Database practitioners can define views as read-only or updatable. If the database system can determine the reverse mapping from the view schema to the schema of the underlying base tables, then the view is updatable. INSERT, UPDATE, and DELETE operations can be performed on updatable views. Read-only views do not support such operations because the DBMS cannot map the changes to the underlying base tables. A view update is done by key preservation.
Some systems support the definition of INSTEAD OF triggers on views.(insert/delete view 必须为其定义trigger) This technique allows the definition of other logic for execution in place of an insert, update, or delete operation on the views. Thus database systems can implement data modifications based on read-only views. However, an INSTEAD OF trigger does not change the read-only or updatable property of the view itself.
In order to insert (update & delete) data to views created using multiple tables, you need to use an ‘Instead of trigger’.
**Please note that ‘After Triggers’ cannot be created for views.
Let’s create an instead of trigger using the following syntax.

CREATE TRIGGER TRGI_VW_PAYMENT ON VW_LAST_PAYMENT_DETAILS
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO STUDENT_PAYMENT
SELECT STD_ID,PAY_AMT,PAY_DATE
FROM INSERTED
END
Now using the above insert syntax, you can insert data without getting any error. If you inspect the ‘STUDENT_PAYMENT’ table you can see that the data has been inserted successfully.
What is the difference between database table and database view?的更多相关文章
- How do I see what character set a database / table / column is in MySQL?
Q: How do I see what the character set that a MySQL database, table and column are in? Is there some ...
- 2.1-2.2 Hive 中数据库(Table、Database)基本操作
官网文档:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL 一.create table 1.官方字段 # # C ...
- SAP技术 - How to create a CDS redirect view for a given database table
Scenario Suppose we have a database table A, and then we create a CDS redirect view B for it, then e ...
- Azure SQL Database (19) Stretch Database 概览
<Windows Azure Platform 系列文章目录> Azure SQL Database (19) Stretch Database 概览 Azure SQL Da ...
- Oracle® Database Patch 19121551 - Database Patch Set Update 11.2.0.4.4 (Includes CPUOct2014) - 傲游云浏览
Skip Headers Oracle® Database Patch 19121551 - Database Patch Set Update 11.2.0.4.4 (Includes CPUOct ...
- Oracle Database 12c Using duplicate standby database from active database Created Active DataGuard
primary database db_name=zwc, db_unique_name=zwc standby database db_name=zwc, db_unique_name=standb ...
- 使用duplicate target database ... from active database复制数据库
使用duplicate target database ... from active database复制数据库 source db:ora11auxiliary db:dupdb 1.修改监听文件 ...
- Teradata Delete Database and Drop Database
DELETE DATABASE and DELETE USER statements delete all data tables, views, and macros from a database ...
- Cannot connect to database because the database client
问题描述: arcgis server10.1 arcgis sde10出现下面问题 Cannot connect to database because the database client ...
随机推荐
- MD5加密方式
MD5加密是一种安全系数比较高的加密方式,具有不可逆的加密特征,就是很难进行破解,现在对MD5加密进行破解的方式还是采用跑数据库的方式,时间比较长,耗费性能比较大,所以一般的破解都是要收费的. C#中 ...
- fpm打包redis3.0.7
1.安装redis tar -xf redis-3.0.7.tar.gz -C /usr/local cd /usr/local && mv redis-3.0.7 redis cd ...
- [视频]MAC中如何单独放大文本字体
我们知道使用MAC触控板的双指合拢手势可以进行放大或缩小操作,但其对应的是整个界面内容的放大及缩小,如果仅对其文本内容进行放大或缩小,可使用快捷键进行操作. 默认的 ”Command” + “=“ ...
- no permissions fastboot
no permissions fastboot 获取fastboot文件 1.编译后得android源码会在目录: andsource2/out/host/linux-x86/bin 产生fastb ...
- CentOS 7 终端设置屏幕分辨率
在grub中我们修改的是/boot/grub/grub.conf,而在grub2中要修改的文件是/boot/grub2/grub.cfg inux16 /vmlinuz-3.10.0-123.el7. ...
- C# 使用隐式或显示实现接口的区别
通俗的来讲,"显示接口实现"就是使用接口名称作为方法名的前缀;而传统的实现方式称之为:"隐式接口实现".费话不说,例子如下: interface IA ...
- 【Web学习日记】——C#引用WebService,从配置文件改变引用地址
开发环境:Win7 32位,开发工具:VS2013,.Net:4.0 初用WebService,很多地方都搞不清楚怎么回事,但稍作研究之后,也就用上了,根本就没有考虑后续事情. 但是,随着项目的进行, ...
- parameter和argument的区别
根据网上一些资料,对parameter和argument的区别,做如下的简单说明.1. parameter是指函数定义中参数,而argument指的是函数调用时的实际参数.2. 简略描述为:param ...
- telnet 时代的 bbs
人类曾经用telnet 来访问 bbs,后来有了www,web 浏览器取代了telnet Telnet协议是TCP/IP协议族中的一员 arp和ping的区别 ping也属于一个通信协议,是TCP/I ...
- telnet命令判断端口是否通不通
以上得出结论80端口不通 如果连接成功,想要退出telnet的话,ctrl+],然后输入quit 查看iptables vi /etc/sysconfig/iptables #编辑防火墙配置文件 ...