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

2021-12-06 00:00:00 oracle

在 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

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

相关文章