当前位置:网站首页>The difference between oracle temporary table and pg temporary table
The difference between oracle temporary table and pg temporary table
2022-08-04 06:06:00 【Big Yellow Cat No. 1】
After joining the job, the master asked to query the difference between the pg temporary table and the oracle global temporary table, as well as the idea of transforming the oracle temporary table to pg, all of which are based on their own practice, and welcome comments and corrections if there are mistakes...
Pg temporary table: The pg temporary table is divided into session-level and transactionallevel.
Session level:Data can be saved throughout the life cycle of the session table, if the current session is ended,Then clear the data in the table and delete the table.During this session, you can directly make changes to the fields and data of the table, and other sessions cannot access the current temporary table.
Transaction level:(1) on commit delete rows: You can create temporary in a session with this commandtable, and change the table fields before and after starting the transaction, You can use the dml statement before the transaction starts, but the content of the table does not change substantially,
(2) On commit drop: It can only be created in a transaction, and the table is automatically deleted after the transaction is ended.
Oracle temp table:span>Oracle temporary tables are divided into session level and transaction level.
Session level:Data can be maintained at the entire session level.
Transaction level:The data in the table will be cleared after commit and rollback
The difference between Pg temporary table and oracle temporary table:
Pg temporary table only exists in the current session, other sessions cannot access the temporary table, and ending the session will delete the temporary table.After the Oracle temporary table is created, although the data between each session is isolated from each other, that is, one session cannot see the data of other sessions, but the defined fields are shared.And the definition of the table will still exist after the session is ended, but the data in the table will be cleared.
Changes to Oracle temporary table fields can only be made when all current sessions do not perform dml operations on the table.If one of the sessions changes the data in the table, the ddl operation is not possible.
Deletion of Oracle temporary table:
Transaction level: Only when all sessions are fully committed can they be deleted.
Session level: All sessions can only be deleted before executing the dml statement on the table.
The idea of oracle temporary table to pg temporary table: first, you need to lock the table so that only the current session can access the temporary table, and you need to release other locks in the table (feelingOracle temporary tables are locked so that the definition of the fields in the table cannot be changed after the data in the field is changed, it is not clear whether there is or what lock is added), and the temporary table should be automatically deleted at the end of the session.(This part is an idea, because it cannot be practically operated for some reasons)
边栏推荐
- (九)哈希表
- flink自定义轮询分区产生的问题
- 剑指 Offer 2022/7/1
- flink-sql自定义函数
- fill_between in Matplotlib; np.argsort() function
- TensorFlow2学习笔记:8、tf.keras实现线性回归,Income数据集:受教育年限与收入数据集
- 【深度学习21天学习挑战赛】备忘篇:我们的神经网模型到底长啥样?——model.summary()详解
- [Deep Learning 21 Days Learning Challenge] 2. Complex sample classification and recognition - convolutional neural network (CNN) clothing image classification
- (十)树的基础部分(二)
- flink-sql大量使用案例
猜你喜欢
随机推荐
Thread 、Handler和IntentService的用法
k3s-轻量级Kubernetes
ThinkPHP5.0.x 反序列化分析
(十)树的基础部分(一)
剑指 Offer 2022/7/12
RecyclerView的用法
Kubernetes基本入门-概念介绍(一)
SQL练习 2022/6/30
智能合约安全——溢出漏洞
Delphi-C side interesting menu operation interface design
自动化运维工具Ansible(2)ad-hoc
SQL练习 2022/7/3
Introduction of linear regression 01 - API use cases
NFT市场以及如何打造一个NFT市场
lmxcms1.4
flink-sql所有表连接器
ISCC2021——web部分
SQL练习 2022/7/2
flink自定义轮询分区产生的问题
Androd Day02