当前位置:网站首页>查询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
边栏推荐
- Integrating database Ecology: using eventbridge to build CDC applications
- Job CE
- 使用ORDER BY 排序
- js win7透明桌面切换背景开始菜单js特效
- Record an error in runtime. Getruntime().Exec ("command")
- Read the recent trends of okaleido tiger and tap the value and potential behind it
- 如何用Redis实现事物以及锁?
- 3D laser slam: Interpretation of logo-loam paper - Introduction
- Unity gets which button (toggle) is selected under togglegroup
- 企业如何成功完成云迁移?
猜你喜欢

LVS+KeepAlived高可用部署实战应用

Explain prefabrication in unity in detail

How to make the design of governance structure more flexible when the homogenization token is combined with NFT?

Three steps to teach you unity serial communication

Unity package exe to read and write excel table files

Unity typewriter teaches you three ways

什么是“安全感”?沃尔沃用它自己独特的理解以及行动来告诉你

EasyNLP中文文图生成模型带你秒变艺术家
Database tuning - connection pool optimization

Nat experiment demonstration (Huawei switch equipment configuration)
随机推荐
作业 ce
一文了解 Rainbond 云原生应用管理平台
Explain several mobile ways of unity in detail
“当你不再是程序员,很多事会脱离掌控”—— 对话全球最大独立开源公司SUSE CTO...
C # basic 1-events and commissions
不懂就问,快速成为容器服务进阶玩家!
Laser slam:logo-loam --- code compilation, installation and gazebo test
How to balance security and performance in SQL?
Thinking and summary of R & D Efficiency
High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation
js图片悬挂样式照片墙js特效
JS page black and white background switch JS special effect
Cartoon JS shooting game source code
js图表散点图例子
js win7透明桌面切换背景开始菜单js特效
PL515 SOT23-5 单/双口 USB 充电协议端口控制器 百盛电子代理商
Explain the imported 3D model in unity
Explain various coordinate systems in unity in detail
网络各层性能测试
Huawei cloud digital asset chain, "chain" connects the digital economy, infinite splendor