当前位置:网站首页>金仓数据库 KingbaseES 插件force_view
金仓数据库 KingbaseES 插件force_view
2022-06-25 10:45:00 【沉舟侧畔千帆过_】
目录
1. force_view介绍
force_view是视图的无效状态,而视图是基于SQL语句结果集的可视化的表,其内容由查询定义。视图有无效和有效两种状态。使用一个无效视图(force_view)时候,若该无效视图经过重新编译依然无效,那么将会抛出错误信息。
2. force_view的产生
创建一个无效视图:
使用create force view创建一个无效视图。创建force view时若依赖检查成功,则创建为一个有效视图,否则创建为一个无效视图。这里依赖检查就是视图编译,视图编译阶段的检查主要包括:依赖对象是否存在、创建者是否有依赖对象的select权限等。create force view vtab as select * from tab; --tab不存在
WARNING: View created with compilation errors
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
----------------
{status=false}
有效视图变成无效视图:
删除视图依赖,改变视图依赖列等会使被依赖视图变成无效状态。
create or replace也可能会将有效视图替换为无效视图。
create table tab(a int);
CREATE TABLE
create force view vtab as select * from tab;
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
------------
drop table tab;
NOTICE: view vtab depends on table tab
DROP TABLE
select reloptions from sys_class where relname = 'vtab';
reloptions
----------------
{status=false}
3. force_view的使用重新编译后依然无效:
使用(查询,插入,更新等)一个无效视图时,会重新编译该视图。若编译失败视图依然无效,抛出错误。create force view vtab as select * from tab; --tab不存在
WARNING: View created with compilation errors
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
----------------
{status=false}
select * from vtab;
ERROR: view "vtab" is still invalid after recompiling
重新编译后有效:
使用一个无效视图时候,会重新编译该视图。若编译成功,视图有效,按用户指令操作该视图。create force view vtab as select * from tab; --tab不存在
WARNING: View created with compilation errors
CREATE VIEW select reloptions from sys_class where relname = 'vtab';
reloptions
----------------
{status=false}
create table tab(a int);
CREATE TABLE
select * from vtab;
a
---
(0 rows)
select reloptions from sys_class where relname = 'vtab';
reloptions
---------------
{status=true}
4. 有效视图的产生创建一个有效视图:
创建视图时候若依赖检查成功则创建为一个有效视图。创建视图 (不带force ),依赖检查失败,视图创建会失败。create table tab(a int);
CREATE TABLE
create force view vtab as select * from tab;
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
------------
create view vtab1 as select * from tab1;
ERROR: relation "tab1" does not exist
LINE 1: create view vtab1 as select * from tab1;
无效视图变成有效视图:
使用一个无效视图,若视图重新编译成功,视图变成有效视图。create force view vtab as select * from tab;
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
----------------
{status=false}
create table tab(a int);
CREATE TABLE
select * from vtab;
a
---
(0 rows)
select reloptions from sys_class where relname = 'vtab';
reloptions
------------
5. 有效视图的使用
create table tab(a int);
CREATE TABLE
insert into tab values(3);
INSERT 0 1
create view vtab as select * from tab;
CREATE VIEW
select reloptions from sys_class where relname = 'vtab';
reloptions
------------
select * from vtab;
a
---
3
6. 视图状态的维护视图状态的维护
create table tab(a int);
CREATE TABLE
create view vtab as select * from tab;
CREATE VIEW
create view vvtab as select * from vtab;
CREATE VIEW
select relname, reloptions from sys_class where relname in ('vtab', 'vvtab');
relname | reloptions
---------+------------
vtab |
vvtab |
(2 rows)
drop table tab;
NOTICE: there are(is) 2 objects that depend(s) on it
DETAIL: view vtab depends on table tab
view vvtab depends on view vtab
DROP TABLE
select relname, reloptions from sys_class where relname in ('vtab', 'vvtab');
relname | reloptions
---------+----------------
vtab | {status=false}
vvtab | {status=false}
(2 rows)
边栏推荐
- 今天16:00 | 中科院计算所研究员孙晓明老师带大家走进量子的世界
- 炒股票开户的话,手机开户安全吗?有谁知道啊?
- Binder explanation of Android interview notes
- OODA working method
- Use of three-level linkage plug-ins selected by provinces and cities
- Is it safe for Guosen Securities to open a securities account
- [image fusion] image fusion based on morphological analysis and sparse representation with matlab code
- Detailed explanation of Android interview notes handler
- CSRF attack
- 每日3题(3)-检查整数及其两倍数是否存在
猜你喜欢

Android之Kotlin语法详解与使用

OpenCV学习(一)---环境搭建

FPGA基于VGA显示字符及图片
![[observation] objectscale: redefining the next generation of object storage, reconstruction and innovation of Dell Technology](/img/82/8cac87231e51698ab17f1274b3a0bd.jpg)
[observation] objectscale: redefining the next generation of object storage, reconstruction and innovation of Dell Technology

CSRF攻击

Oracle彻底卸载的完整步骤

WPF prism framework

XSS攻击

Your driver settings have been set to force 4x antialiasing in OpenGL applications
![[paper reading | deep reading] drne:deep recursive network embedding with regular equivalence](/img/48/4e8d367b49f04a2a71a2c97019501f.png)
[paper reading | deep reading] drne:deep recursive network embedding with regular equivalence
随机推荐
New school: no fraud Economics
Is it safe to speculate in stocks by mobile phone?
Is it safe to open a stock account on the compass?
[file containing vulnerability-03] six ways to exploit file containing vulnerabilities
Macro application connector\
网络协议学习---LLDP协议学习
Application of global route guard
每日3題(3)-檢查整數及其兩倍數是否存在
Software testing to avoid being dismissed during the probation period
Task03 probability theory
2022年PMP项目管理考试敏捷知识点(2)
VW VH adaptation of mobile terminal
This is enough for request & response
Daily Mathematics Series 52: February 20
性能之文件系统篇
[dynamic planning] - Digital triangle
On binary tree
FPGA基于VGA显示字符及图片
Is it safe to open a securities account in changtou school by mobile phone?
TASK03|概率论