在 Oracle 中创建变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2708888/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:30:13  来源:igfitidea点击:

Create Variable In Oracle

oraclevariables

提问by GigaPr

What is the Oracle equivalent of this MS SQL Server notation?

这个 MS SQL Server 表示法的 Oracle 等价物是什么?

DECLARE @Variable INT
SET @Variable = 1

回答by FrustratedWithFormsDesigner

In PL/SQL, you have a declare block:

在 PL/SQL 中,您有一个声明块:

declare
    x integer := 1;
    ...
begin
    ...
end;

If you are writing an SQL*Plus script, you use variableto declare a bind variable

如果您正在编写 SQL*Plus 脚本,则variable用于声明绑定变量

variable x integer := 1;

It's also possible to definevariables.

也可以定义变量。

回答by Pablo Santa Cruz

In PL/SQL:

在 PL/SQL 中:

DECLARE
  a number;
BEGIN
  a := 1;
END;

You can paste this code in SQLPlus to run it.

您可以将此代码粘贴到 SQLPlus 中以运行它。