Chinaunix

标题: SHELL如何同同时存储2个数据 [打印本页]

作者: abcdex    时间: 2016-07-18 20:47
标题: SHELL如何同同时存储2个数据
伪代码如下

从表中取2个变量,然后循环,每次根据这2个变量抽取一些新的变量,问题是,这2个变量应该如何存放,又如何被用到循环里面

for x in (select owern,table from xxx) ;
do
    select value from x.owenr.x.table ;
done
作者: seanking1987    时间: 2016-07-19 14:49
回复 1# abcdex


将第一次sql取到的数据放置到数组中。
从数组中读取数据,作为第二次sql的条件执行

作者: abcdex    时间: 2016-07-19 15:55
seanking1987 发表于 2016-07-19 14:49
回复 1# abcdex


能给一个例子吗?
作者: jason680    时间: 2016-07-19 16:26
$ echo -e "owner table\nuser 123" | while read owner table; do echo $owner,$table; done
owner,table
user,123

作者: abcdex    时间: 2016-07-19 16:42
jason680 发表于 2016-07-19 16:26
$ echo -e "owner table\nuser 123" | while read owner table; do echo $owner,$table; done
owner,table ...




不行

,我的是要配合ORACLE数据库,类似下面这种,按照你的方法是不行的,觉得只用使用数组,一个数组中能放2个变量。

for owner,tab_name in `$ORACLE_HOME/bin/sqlplus<<!
conn / as sysdba
select owner,table_name from dba_tables where owner='OE';

do
  nohup  sqlplus /nolog <<eof  &
    conn /as sysdba
    select count(1) from $owner.$tab_name;
   eof
done
作者: zxy877298415    时间: 2016-07-19 20:11
回复 5# abcdex

sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
set pagesize 0
set verify off
set echo off
set heading off
select owner||'.'||table_name from dba_tables where owner='OE';
exit
EOF
   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2