【问题标题】:SQL variable creationSQL 变量创建
【发布时间】:2019-03-11 19:52:40
【问题描述】:

下面的语言是什么?我在一个 .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 oracle variables sqlplus


    【解决方案1】:

    看起来像 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>
    

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

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 2018-06-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2018-10-31
      相关资源
      最近更新 更多