Rem插入sqlplus?

时间:2016-09-03 12:24:02

标签: oracle-sqldeveloper sqlplus

在SQL Developer中我正在运行:

SPOOL C:\Export15.sql;



select /*insert*/* from Arithmisi ;

SPOOL OFF;

输出是这样的:

REM INSERTING into Arithmisi
SET DEFINE OFF;
Insert into "Arithmisi" (ARITHMOS) values ('3263');
Insert into "Arithmisi" (ARITHMOS) values ('3294');
Insert into "Arithmisi" (ARITHMOS) values ('3295');
Insert into "Arithmisi" (ARITHMOS) values ('3296');
Insert into "Arithmisi" (ARITHMOS) values ('3297');
Insert into "Arithmisi" (ARITHMOS) values ('3298');
Insert into "Arithmisi" (ARITHMOS) values ('3299');
Insert into "Arithmisi" (ARITHMOS) values ('3300');
Insert into "Arithmisi" (ARITHMOS) values ('3301');
Insert into "Arithmisi" (ARITHMOS) values ('3302');
Insert into "Arithmisi" (ARITHMOS) values ('3303');
Insert into "Arithmisi" (ARITHMOS) values ('3304');
Insert into "Arithmisi" (ARITHMOS) values ('3305');

然后我在sql plus中运行相同的命令,但结果如下:

ARITHMOS

  3263                                                                      
  3294                                                                      
  3295                                                                      
  3296                                                                      
  3297                                                                      
  3298                                                                      
  3299                                                                      
  3300                                                                      
  3301                                                                      
  3302                                                                      
  3303                                                                      

ARITHMOS

  3304                                                                      
  3305                                                                      

如何用sql plus编写产生与SQL Developer相同的输出?

1 个答案:

答案 0 :(得分:1)

似乎亚历克斯帮助完成了最终目标,但我会抓住你回答你问的问题。您可以通过将插入作为select的一部分来获取sqlplus中的插入,但这有点单调乏味。

对于一个列表:

select 'insert into TABLE_NAME values ('''||FIELD_NAME||'''); ' from TABLE_NAME;

对于多列:

select 'insert into TABLE_NAME values ('''
||FIELD1_NAME||''','''                
||FIELD2_NAME||''','''              
||FIELD3_NAME||'''); ' 
from TABLE_NAME;

在你的情况下:

SPOOL C:\Export15.sql;
select 'insert into Arithmisi values ('''||ARITHMOS||'''); ' from Arithmisi;
SPOOL OFF;

我希望这有帮助!