oracle 的sqlplus 的声明变量和定义变量

在SQLPLUS里面,我们可以使用show all来查看系统的一些设置。


sql>  show all;


appinfo 为 OFF 并且已设置为 "SQL*Plus"

arraysize 15

autocommit OFF

autoprint OFF

autorecovery OFF

autotrace OFF

blockterminator "." (hex 2e)

btitle OFF 为下一条 SELECT 语句的前几个字符

cmdsep OFF

colsep " "

compatibility version NATIVE

concat "." (hex 2e)

copycommit 0

COPYTYPECHECK 为 ON

define "&" (hex 26)

describe DEPTH 1 LINENUM OFF INDENT ON

echo OFF

editfile "afiedt.buf"

embedded OFF

escape OFF

用于 6 或更多行的 FEEDBACK ON

flagger OFF

flush ON

heading ON

headsep "|" (hex 7c)

instance "local"

linesize 80

lno 14

loboffset 1

logsource ""

long 80

longchunksize 80

markup HTML OFF HEAD "<style type='text/css'> body {font:10pt Arial,Helvetica,sa

ns-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-seri

f; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-s

erif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0

px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; backgroun

d:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-s

erif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; ma

rgin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} h2 {font:bold 10pt Ar

ial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-t

op:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#66330

0; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</

style><title>SQL*Plus Report</title>" BODY "" TABLE "border='1' width='90%' alig

n='center' summary='Script output'" SPOOL OFF ENTMAP ON PREFORMAT OFF

newpage 1

null ""

numformat ""

numwidth 10

pagesize 14

PAUSE 为 OFF

pno 0

recsep WRAP

recsepchar " " (hex 20)

release 1002000100

repfooter OFF  为 NULL

repheader OFF  为 NULL

serveroutput OFF

shiftinout INVISIBLE

showmode OFF

spool OFF

sqlblanklines OFF

sqlcase MIXED

sqlcode 0

sqlcontinue "> "

sqlnumber ON

sqlpluscompatibility 10.2.0

sqlprefix "#" (hex 23)

sqlprompt "SQL> "

sqlterminator ";" (hex 3b)

suffix "sql"

tab ON

termout ON

timing OFF

trimout ON

trimspool OFF

ttitle OFF 为下一条 SELECT 语句的前几个字符

underline "-" (hex 2d)

USER 为 "SYS"

verify ON

wrap : 将换至下一行


这些都是系统的一些设置变量。


实际上,ORACLE还提供了自己定义变量  包括define 变量和绑定变量


sql > define x


SQL> define x='abc'

要引用这个变量,需要使用and符号,假如是字符串,需要加上单引号。


SQL> select '&x' from dual;

原值    1: select '&x' from dual

新值    1: select 'abc' from dual


'AB

---

abc


================================

绑定变量

要想使用绑定变量,需要先定义它


variable x varchar2(10)


begin


  :x := 'hello';


end;


/


print :x


define 变量总是被sqlplus 扩展的字符串,而declared变量可以被SQL和PLSQL作为真正的绑定变量使用






猜你喜欢

转载自chenhua-1984.iteye.com/blog/1474424