Oracle 是否有等效于 SQL Server 的表变量?

2023-09-20数据库问题
3

本文介绍了Oracle 是否有等效于 SQL Server 的表变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在 SQL Server 中,您可以声明一个表变量(DECLARE @table TABLE),该变量在脚本运行时生成,然后从内存中删除.

In SQL Server, you can declare a table variable (DECLARE @table TABLE), which is produced while the script is run and then removed from memory.

oracle 有没有类似的功能?还是我坚持使用对我的硬盘进行分段的 CREATE/DROP 语句?

Does Oracle have a similar function? Or am I stuck with CREATE/DROP statements that segment my hard drive?

推荐答案

是.

在 a 中声明 TABLE TYPE 变量PL/SQL 声明块.表变量也称为按表索引或大批.表变量包含一个列必须是标量或记录数据类型加上主键输入 BINARY_INTEGER.语法:

Declare TABLE TYPE variables in a PL/SQL declare block. Table variables are also known as index-by table or array. The table variable contains one column which must be a scalar or record datatype plus a primary key of type BINARY_INTEGER. Syntax:

声明类型 type_name 是表(列类型 |变量%TYPE |表.列%TYPE[非空]按二进制整数索引;

DECLARE TYPE type_name IS TABLE OF (column_type | variable%TYPE | table.column%TYPE [NOT NULL] INDEX BY BINARY INTEGER;

-- 然后声明一个这种类型的 TABLE 变量:variable_name type_name;

-- Then to declare a TABLE variable of this type: variable_name type_name;

-- 为 TABLE 变量赋值:变量名(n).field_name :='一些文字';-- 其中 'n' 是指标值

-- Assigning values to a TABLE variable: variable_name(n).field_name := 'some text'; -- Where 'n' is the index value

参考:http://www.iselfschooling.com/syntax/OraclePLSQLSyntax.htm

您可能还想看看全局临时表

这篇关于Oracle 是否有等效于 SQL Server 的表变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

SQL 子句“GROUP BY 1"是什么意思?意思是?
What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)...
2024-04-16 数据库问题
62

为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同
Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)...
2024-04-16 数据库问题
13

如何在MySQL中为每个组选择第一行?
How to select the first row for each group in MySQL?(如何在MySQL中为每个组选择第一行?)...
2024-04-16 数据库问题
13

MySQL - 获取最低值
MySQL - Fetching lowest value(MySQL - 获取最低值)...
2024-04-16 数据库问题
8

在 cmakelist.txt 中添加和链接 mysql 库
Add and link mysql libraries in a cmakelist.txt(在 cmakelist.txt 中添加和链接 mysql 库)...
2024-04-16 数据库问题
41

考勤数据库的良好数据库设计(架构)是什么?
What is a good database design (schema) for a attendance database?(考勤数据库的良好数据库设计(架构)是什么?)...
2024-04-16 数据库问题
7