Oracle变量定义的三种方式(define,variable,declare)学习笔记

1、define(即host变量)

Host变量主要作用是起到一个替代变量的作用,是主机环境可以和oracle进行交互的一个媒介。 通过define定义host变量的时候必须指定变量名和变量的值,如果变量名已经存在于host变量中,则自动覆盖,这个值不可以指定类型,一律按char存储。 DEFINE 变量只在当前session环境中有效。

(1).语法:

define variable_name = value

(2).声明和初始化DEFINE变量

//声明define变量的时候必须同时初始化赋值变量
SQL> define num=1;

另外可以使用define命令显示单个(define variable_name,不能显示多个)或全部(define)的host变量的值和类型(类型都是char)。


(3).显示指定的DEFINE变量值和类型

//使用define def_name命令显示指定DEFINE变量的值和类型(DEFINE变量类型都为char)
SQL> define num;
DEFINE num              = "1" (CHAR)

(4).显示所有的DEFINE变量值和类型

//使用define显示所有DEFINE变量的值和类型(DEFINE变量类型都为char)
SQL> define
DEFINE _CONNECT_IDENTIFIER = "TOPPROD" (CHAR)
DEFINE _SQLPLUS_RELEASE = "902000100" (CHAR)
DEFINE _EDITOR         = "Notepad" (CHAR)
DEFINE _O_VERSION      = "Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Producti
With the Partitioning, OLAP, Data Mining and Real Application Testing options" (CHAR)
DEFINE _O_RELEASE      = "1102000300" (CHAR)

了解对于host变量启用和关闭的命令是:set define on和set define off。


(5).关闭DEFINE变量定义功能

//关闭define
SQL> set define off;
SQL> define num=1;
SQL> select * from occ_file where rownum=#

select * from occ_file where rownum=&num

ORA-01008: 并
  • 3
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
In a qmake (.pro) file, you can define variables using the `VARIABLE_NAME = value` syntax. For example: ``` # Define a variable MY_PROJECT_NAME = MyAwesomeProject # Use the variable in other parts of the .pro file TARGET = $$MY_PROJECT_NAME ``` In the above example, we define a variable `MY_PROJECT_NAME` and set its value to `"MyAwesomeProject"`. We then use this variable in the `TARGET` variable, which is used to set the name of the output binary. You can also use variables to define paths, compiler flags, and other project-specific settings. For example: ``` # Define a variable for the include directories INCLUDEPATH += $$PWD/include # Define a variable for the compiler flags QMAKE_CXXFLAGS += -Wall -Wextra -pedantic # Use the variables in other parts of the .pro file SOURCES += src/main.cpp src/utils.cpp HEADERS += include/utils.h LIBS += -L$$PWD/lib -lmylib ``` In the above example, we define a variable for the include directories (`INCLUDEPATH`) and set its value to the `include` directory in the current project directory (`$$PWD/include`). We also define a variable for the compiler flags (`QMAKE_CXXFLAGS`) and set it to some common flags for warnings (`-Wall -Wextra -pedantic`). We then use these variables in other parts of the .pro file. For example, we add some source files to the `SOURCES` variable, and include some header files in the `HEADERS` variable. We also include a library (`mylib`) in the `LIBS` variable, and specify its location using the `$$PWD` variable.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值