当前位置:网站首页>金仓数据库 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)
边栏推荐
猜你喜欢

Use of three-level linkage plug-ins selected by provinces and cities

中國信通院沈瀅:字體開源協議——OFL V1.1介紹及合規要點分析
![[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

Binder explanation of Android interview notes

CSRF attack
![[today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world](/img/f7/b3239802d19d00f760bb3174649a89.jpg)
[today in history] June 24: Netease was established; The first consumer electronics exhibition was held; The first webcast in the world
![[file containing vulnerability-03] six ways to exploit file containing vulnerabilities](/img/4f/495c852eb0e634c58e576d911a2c14.png)
[file containing vulnerability-03] six ways to exploit file containing vulnerabilities

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

Opencv learning (II) -- installing opencv on raspberry pie

报名开启|飞桨黑客马拉松第三期如约而至,久等啦
随机推荐
手机办理长投学堂证券开户靠谱安全吗?
新学派:不诈骗经济学
Nuxtjs actual combat case
Think about it
一文了解Prometheus
16 种企业架构策略
After reading this article, I will teach you to play with the penetration test target vulnhub - drivetingblues-7
[file containing vulnerability-03] six ways to exploit file containing vulnerabilities
数组结构整理
视频会议一体机的技术实践和发展趋势
Unreal Engine graphics and text notes: use VAT (vertex animation texture) to make Houdini end on Houdini special effect (ue4/ue5)
Is it safe to open a securities account in changtou school by mobile phone?
Garbage collection mechanism
中國信通院沈瀅:字體開源協議——OFL V1.1介紹及合規要點分析
Opencv learning (II) -- installing opencv on raspberry pie
垃圾回收机制
撸一个随机数生成器
OpenCV学习(二)---树莓派上安装opencv
Learn to learn self-study [learning to learn itself is more important than learning anything]
Daily 3 questions (3) - check whether integers and their multiples exist