【问题标题】:Oracle sql developer| export from query to a tableOracle sql开发者|从查询导出到表
【发布时间】:2022-01-12 14:38:23
【问题描述】:

美好的一天, 在 DBeaver 数据库管理器中,我们能够将数据直接从查询传输到我们创建的表。我们右键单击>执行>导出到表。 任何人都可以帮助我在 oracle 开发人员环境中做同样的事情。 在这里,我在同一个连接中创建了一个表,并希望将查询结果存储到表中。 谢谢

【问题讨论】:

  • 您可以创建表 xyz 为.....(将您的查询放在这里)
  • 或者如果是现有表,insert into your_table (col1, ....) select ...

标签: sql oracle oracle-sqldeveloper


【解决方案1】:

右击你的桌子。

选择表格 - 复制。

给它一个名字,然后选中“包含数据”

您可以通过单击 SQL 面板查看我们即将运行的代码。

declare
  l_sql varchar2(32767);
  c_tab_comment varchar2(32767);
  procedure run(p_sql varchar2) as
  begin 
     execute immediate p_sql;
     
  end; 
begin
run('create table "HR".BEERS_COPY as select * from "HR"."BEERS" where '||11||' = 11');
  begin
  select comments into c_tab_comment from sys.all_TAB_comments where owner = 'HR' and table_name = 'BEERS' and comments is not null;
  run('comment on table HR.BEERS_COPY is '||''''||REPLACE(c_tab_comment, q'[']', q'['']')||'''');

  for tc in (select column_name from sys.all_tab_cols where owner = 'HR' and table_name = 'BEERS')
      loop
     for c in (select comments from sys.all_col_comments where owner = 'HR' and table_name = 'BEERS' and column_name=tc.column_name) 
     loop 
     run ('comment on column HR.BEERS_COPY.'||tc.column_name||' is '||''''||REPLACE(c.comments, q'[']', q'['']')||'''');
   end loop;
  end loop;
  EXCEPTION
    WHEN OTHERS THEN NULL; 
  end;
end;
                

所以基本上是 CTAS + 我们为您抓取 cmets。

免责声明:我是 SQL Developer 的产品经理和 Oracle 员工。

【讨论】:

    猜你喜欢
    • 2016-07-27
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 2013-12-04
    相关资源
    最近更新 更多