当前位置:网站首页>查询oracle视图创建语句及如何向视图中插入数据[通俗易懂]
查询oracle视图创建语句及如何向视图中插入数据[通俗易懂]
2022-07-28 18:53:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
今天由于要测试接口,需要在数据库中插入一些测试数据。但当我在向数据库插入数据的时候,发现接口查询的是视图并不是表,所以将遇到的问题在这里记录一下。
1. 向视图插入数据的时候分两种情况
1.1 对于简单视图(视图建立在一张表上),跟表一样直接插入数据就好;
1.2 对于复杂视图(视图建立时包含多表关联、分组、聚合函数),这个时候不能直接插入数据,应该创建一个 INSTEAD 类型的触发器来操作,将要插入的数据插入到组成视图的各个表中。
格式:
create trigger [触发器名]
on [视图名]
instead of insert
as
begin
--声明变量;
--从inserted表中查出所有列的数据,分别赋给声明好的变量;
--用上面的数据向第一张表插入数据
--用上面的数据向第二张表插入数据
end而我们要知道这个视图是简单视图还是复杂视图,就需要去看视图的创建语句。
2. 查看视图创建的 sql 语句也有以下两种方法
2.1 第一种(注意视图名需要全大写)
select dbms_metadata.get_ddl('VIEW', '视图名') from dual;执行之后点击下面这个按钮就可以看到语句:
2.2 第二种
select text from user_views where view_name = '视图名';执行之后也是一样需要点击按钮才能看到:
好了,今天的分享就到这里吧,不当之处,希望大家多给建议。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128646.html原文链接:https://javaforall.cn
边栏推荐
- Alibaba cloud MSE supports go language traffic protection
- UE4 3dui widget translucent rendering blur and ghosting problems
- Mongoose condition queries part of the data of the specified attribute
- Nat experiment demonstration (Huawei switch equipment configuration)
- The 678th operation
- Explain prefabrication in unity in detail
- PostgreSQL数据库删库前是不是需要把所有连接断开才能删除?
- 漂亮的蓝色背景表单输入框样式
- js飞入js特效弹窗登录框
- Leetcode:2141. The longest time to run n computers at the same time [the maximum value is two points]
猜你喜欢
Database tuning - connection pool optimization

一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力

How to balance security and performance in SQL?

Introduction to redis II: RedHat 6.5 installation and use

Integrating database Ecology: using eventbridge to build CDC applications

什么是数据中台?数据中台带来了哪些价值?_光点科技

Job CE

Ask if you don't understand, and quickly become an advanced player of container service!

微信小程序的分包加载

什么是“安全感”?沃尔沃用它自己独特的理解以及行动来告诉你
随机推荐
Redis入门一:Redis实战读书笔记
[工具类] Map的util包, 常用 实体类转化为map等操作
Laser slam:logo-loam --- code compilation, installation and gazebo test
Space shooting Lesson 11: sound and music
[C language brush questions] explanation of linked list application
Unity performance optimization scheme arrangement
Interesting pictures and words
Integrating database Ecology: using eventbridge to build CDC applications
Pl515 SOT23-5 single / Dual Port USB charging protocol port controller Parkson electronic agent
Establishment of flask static file service
Explain the script data transmission and notification in unity
Three deletion strategies and eviction algorithm of redis
Network layer performance test
Space shooting Lesson 13: explosion effect
JS fly into JS special effect pop-up login box
Understanding of C # delegate
PL515 SOT23-5 单/双口 USB 充电协议端口控制器 百盛电子代理商
Lvs+keepalived high availability deployment practical application
Three steps to teach you unity serial communication
Talking about canvas and three rendering modes in unity