SQL 变量创建

SQL variable creation

下面是什么语言?我在一个 .sql 文件中 运行 穿过这个,以前从未见过这个……我猜我们正在创建变量,但从未见过这样做的。

column set_schema_pow new_value schema_pow

select variable_value set_schema_pow 
from &schema..var 
where
loc = 'PROD' 
and atom = '&vta' 
and variable_name = 'schema_pow';

看起来像 SQL*Plus。

SQL> create table var (variable_value number, loc varchar2(5), atom varchar2(5), variable_name varchar2(10));

Table created.

SQL> set ver off
SQL>
SQL> column set_schema_pow new_value schema_pow
SQL>
SQL> select variable_value set_schema_pow
  2  from &schema..var
  3  where
  4  loc = 'PROD'
  5  and atom = '&vta'
  6  and variable_name = 'schema_pow';
Enter value for schema: scott
Enter value for vta: a

no rows selected

SQL>

甚至这个(将一些数据存储到 table):

SQL> insert into var values (100, 'PROD', 'a', 'schema_pow');

1 row created.

SQL> column set_schema_pow new_value schema_pow
SQL>
SQL> select variable_value set_schema_pow
  2  from &schema..var
  3  where
  4  loc = 'PROD'
  5  and atom = '&vta'
  6  and variable_name = 'schema_pow';
Enter value for schema: scott
Enter value for vta: a

SET_SCHEMA_POW
--------------
           100

SQL>