在我的SQL脚本中,我可以定义如下变量:
DEFINE x=100;
并像一样使用
CREATE TABLE A&x AS ...;
结果将是CCD_ 1(级联字符串(。
但我想在类似的查询中获得CREATE TABLE A100B AS ...
(B后缀(:
CREATE TABLE A&xB AS ...;
但是Oracle/SQL知道存在xB
变量
如何在SQL:中分离变量(名称(
CREATE TABLE A&{x}B AS ...;
这行不通!
(如${x}
i PHP(
它只是一个很小的点。
SQL> define x=100
SQL> create table a&x.b as select * from dual;
old 1: create table a&x.b as select * from dual
new 1: create table a100b as select * from dual
Table created.
SQL> select * from a100b;
D
-
X
SQL>
这里,以防您错过:
create table a&x.b
^
|
here
有什么意义?SQLPlus串联字符。默认情况下,它是一个点。它告诉SQLPlus变量名的结束位置。
如果您需要更多帮助:
SQL> help set
SET
---
Sets a system variable to alter the SQL*Plus environment settings
for your current session. For example, to:
- set the display width for data
- customize HTML formatting
- enable or disable printing of column headings
- set the number of lines per page
SET system_variable value
where system_variable and value represent one of the following clauses:
APPI[NFO]{OFF|ON|text} NEWP[AGE] {1|n|NONE}
ARRAY[SIZE] {15|n} NULL text
AUTO[COMMIT] {OFF|ON|IMM[EDIATE]|n} NUMF[ORMAT] format
<snip>
---------------------
CON[CAT] {.|c|ON|OFF} [FOR[MAT] {WRA[PPED] |
---------------------
Here it is!