发布网友 发布时间:2022-04-21 19:48
共4个回答
懂视网 时间:2022-04-09 00:23
main.sql 注意,需要在sqlplus下运行 非plsql命令行下 set linesize 200 set term off verify off feedback off pagesize 999 set markup html on entmap ON spool on preformat off spool test_tables.xls @get_tables.sql spool off exitsql脚本,get_tables.sql
--get_tables.sql select * from all_objects where rownum<=1000;
然后在sqlplus下运行main.sql
使用包体编程:
create or replace package smt_xlsx_maker_pkg is /****************************************************************************** NAME: SMT_XLSX_MAKER_PKG PURPOSE: XLSX 生成 Pkg,主要是从Oracle数据库端生成Xlsx二进制的文件。 REVISIONS: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 2011/2/19 Anton Scheffer 1,New Create the pkg 1.1 2015/6/10 Sam.T 1.优化核心处理生成xlsx的代码,使得生成文档的执行效率大大提高! 1.1 2015/6/10 Sam.T 1.query2sheet增加绑定变量的可选输入参数。 1.2 2015/6/15 Sam.T 1.代码增加调试模式。直接设置G_DEBUG_MODE变量即可。 1.2 2015/6/20 Sam.T 1.为方便使用,再次封装一些简单易用的过程,生成xlsx文档 1.2 2015/7/5 Sam.T 1.单条SQL生成xlsx文档的内容,增加是否显示foot,以及显示的行数。 jinzhao 解决数据量较大情况下导出excel报错xml的问题。将dbms_lob.writeappend修改为dbms_lob.append ******************************************************************************/ --------- /********************************************** ****************************************************************************** Copyright (C) 2011, 2012 by Anton Scheffer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************** ******************************************** */ /* 使用方法: declare l_sql varchar2(30000); begin l_sql := ‘select * from all_objects‘; smt_xlsx_maker_pkg.query2sheet(l_sql, true, ‘XLS_DIR‘, ‘Export2.xlsx‘); end; 除此之外,基本上Excel 中有的效果它都可以生成。 以下一个例子,包括居中,合并单元格,底色,新增工作表等: begin smt_xlsx_maker_pkg.clear_workbook; smt_xlsx_maker_pkg.new_sheet; smt_xlsx_maker_pkg.cell(5, 1, 5); smt_xlsx_maker_pkg.cell(3, 1, 3); smt_xlsx_maker_pkg.cell(2, 2, 45); smt_xlsx_maker_pkg.cell(3, 2, ‘Anton Scheffer‘, p_alignment => smt_xlsx_maker_pkg.get_alignment(p_wraptext => true)); smt_xlsx_maker_pkg.cell(1, 4, sysdate, p_fontid => smt_xlsx_maker_pkg.get_font(‘Calibri‘, p_rgb => ‘FFFF0000‘)); smt_xlsx_maker_pkg.cell(2, 4, sysdate, p_numfmtid => smt_xlsx_maker_pkg.get_numfmt(‘dd/mm/yyyy h:mm‘)); smt_xlsx_maker_pkg.cell(3, 4, sysdate, p_numfmtid => smt_xlsx_maker_pkg.get_numfmt(smt_xlsx_maker_pkg.orafmt2excel(‘dd/mon/yyyy‘))); smt_xlsx_maker_pkg.cell(5, 5, 75, p_borderid => smt_xlsx_maker_pkg.get_border(‘double‘, ‘double‘, ‘double‘, ‘double‘)); smt_xlsx_maker_pkg.cell(2, 3, 33); smt_xlsx_maker_pkg.hyperlink(1, 6, ‘http://www.cnblogs.com/mellowsmile‘, ‘jinzhao site‘); smt_xlsx_maker_pkg.cell(1, 7, ‘Some merged cells‘, p_alignment => smt_xlsx_maker_pkg.get_alignment(p_horizontal => ‘center‘)); smt_xlsx_maker_pkg.mergecells(1, 7, 3, 7); for i in 1 .. 5 loop smt_xlsx_maker_pkg.comment(3, i + 3, ‘Row ‘ || (i + 3), ‘Anton‘); end loop; smt_xlsx_maker_pkg.new_sheet; smt_xlsx_maker_pkg.set_row(1, p_fillid => smt_xlsx_maker_pkg.get_fill(‘solid‘, ‘FFFF0000‘)); for i in 1 .. 5 loop smt_xlsx_maker_pkg.cell(1, i, i); smt_xlsx_maker_pkg.cell(2, i, i * 3); smt_xlsx_maker_pkg.cell(3, i, ‘x ‘ || i * 3); end loop; smt_xlsx_maker_pkg.query2sheet(‘select rownum, x.* , case when mod( rownum, 2 ) = 0 then rownum * 3 end demo , case when mod( rownum, 2 ) = 1 then ‘‘demo ‘‘ || rownum end demo2 from dual x connect by rownum <= 5‘); smt_xlsx_maker_pkg.save(‘XLS_DIR‘, ‘Export3.xlsx‘); end; */ g_debug_mode boolean := false; ---DBMS_OUTPUT直接输出/FILE_OUTPUT文档输出/REQUEST_OUTPUT请求日志输出/CONTEXT_OUTPUT 将日志改为上下文输出 g_debug_type varchar2(240) := ‘DBMS_OUTPUT‘; ---绑定变量用的临时表变量 type rec_col_value is record( col_id number(3), col_value varchar2(2400)); type tab_col_value is table of rec_col_value index by binary_integer; -- type tp_alignment is record( vertical varchar2(11), horizontal varchar2(16), wraptext boolean); -- procedure clear_workbook; -- procedure new_sheet(p_sheetname varchar2 := null); -- function orafmt2excel(p_format varchar2 := null) return varchar2; -- function get_numfmt(p_format varchar2 := null) return pls_integer; -- function get_font(p_name varchar2, p_family pls_integer := 2, p_fontsize number := 11, p_theme pls_integer := 1, p_underline boolean := false, p_italic boolean := false, p_bold boolean := false, p_rgb varchar2 := null -- this is a hex ALPHA Red Green Blue value ) return pls_integer; -- function get_fill(p_patterntype varchar2, p_fgrgb varchar2 := null -- this is a hex ALPHA Red Green Blue value ) return pls_integer; -- function get_border(p_top varchar2 := ‘thin‘, p_bottom varchar2 := ‘thin‘, p_left varchar2 := ‘thin‘, p_right varchar2 := ‘thin‘) /* none thin medium dashed dotted thick double hair mediumDashed dashDot mediumDashDot dashDotDot mediumDashDotDot slantDashDot */ return pls_integer; -- function get_alignment(p_vertical varchar2 := null, p_horizontal varchar2 := null, p_wraptext boolean := null) /* horizontal center centerContinuous distributed fill general justify left right */ /* vertical bottom center distributed justify top */ return tp_alignment; -- procedure cell(p_col pls_integer, p_row pls_integer, p_value number, p_numfmtid pls_integer := null, p_fontid pls_integer := null, p_fillid pls_integer := null, p_borderid pls_integer := null, p_alignment tp_alignment := null, p_sheet pls_integer := null); -- procedure cell(p_col pls_integer, p_row pls_integer, p_value varchar2, p_numfmtid pls_integer := null, p_fontid pls_integer := null, p_fillid pls_integer := null, p_borderid pls_integer := null, p_alignment tp_alignment := null, p_sheet pls_integer := null); -- procedure cell(p_col pls_integer, p_row pls_integer, p_value date, p_numfmtid pls_integer := null, p_fontid pls_integer := null, p_fillid pls_integer := null, p_borderid pls_integer := null, p_alignment tp_alignment := null, p_sheet pls_integer := null); -- procedure hyperlink(p_col pls_integer, p_row pls_integer, p_url varchar2, p_value varchar2 := null, p_sheet pls_integer := null); -- procedure comment(p_col pls_integer, p_row pls_integer, p_text varchar2, p_author varchar2 := null, p_width pls_integer := 150 -- pixels , p_height pls_integer := 100 -- pixels , p_sheet pls_integer := null); -- procedure mergecells(p_tl_col pls_integer -- top left , p_tl_row pls_integer, p_br_col pls_integer -- bottom right , p_br_row pls_integer, p_sheet pls_integer := null); -- procedure list_validation(p_sqref_col pls_integer, p_sqref_row pls_integer, p_tl_col pls_integer -- top left , p_tl_row pls_integer, p_br_col pls_integer -- bottom right , p_br_row pls_integer, p_style varchar2 := ‘stop‘ -- stop, warning, information , p_title varchar2 := null, p_prompt varchar := null, p_show_error boolean := false, p_error_title varchar2 := null, p_error_txt varchar2 := null, p_sheet pls_integer := null); -- procedure list_validation(p_sqref_col pls_integer, p_sqref_row pls_integer, p_defined_name varchar2, p_style varchar2 := ‘stop‘ -- stop, warning, information , p_title varchar2 := null, p_prompt varchar := null, p_show_error boolean := false, p_error_title varchar2 := null, p_error_txt varchar2 := null, p_sheet pls_integer := null); -- procedure defined_name(p_tl_col pls_integer -- top left , p_tl_row pls_integer, p_br_col pls_integer -- bottom right , p_br_row pls_integer, p_name varchar2, p_sheet pls_integer := null, p_localsheet pls_integer := null); -- procedure set_column_width(p_col pls_integer, p_width number, p_sheet pls_integer := null); -- procedure set_column(p_col pls_integer, p_numfmtid pls_integer := null, p_fontid pls_integer := null, p_fillid pls_integer := null, p_borderid pls_integer := null, p_alignment tp_alignment := null, p_sheet pls_integer := null); -- procedure set_row(p_row pls_integer, p_numfmtid pls_integer := null, p_fontid pls_integer := null, p_fillid pls_integer := null, p_borderid pls_integer := null, p_alignment tp_alignment := null, p_sheet pls_integer := null); -- procedure freeze_rows(p_nr_rows pls_integer := 1, p_sheet pls_integer := null); -- procedure freeze_cols(p_nr_cols pls_integer := 1, p_sheet pls_integer := null); -- procedure freeze_pane(p_col pls_integer, p_row pls_integer, p_sheet pls_integer := null); -- procedure set_autofilter(p_column_start pls_integer := null, p_column_end pls_integer := null, p_row_start pls_integer := null, p_row_end pls_integer := null, p_sheet pls_integer := null); -- function finish return blob; -- procedure save(p_directory varchar2, p_filename varchar2); -- ---当p_footer设定参数为真,这个g_query2sheet_footer有值,则会显示这个值的内容。没有则默认是Generated xxxx ---有一点说明的是,&ROWS 字段会被自动替换为结果返回的行数。 g_query2sheet_footer varchar2(1000); g_query2sheet_rows number; --结果返回的是多少行记录 --这个是这个程序的"完全体" procedure query2sheet(p_sql varchar2, p_col_value_tab smt_xlsx_maker_pkg.tab_col_value ---运行的动态SQL的绑定变量 , p_column_headers boolean := true, p_directory varchar2 := null, p_filename varchar2 := null, p_sheet pls_integer := null, p_footer boolean := true, x_retcode out number ---0:成功 非0:失败( 或者:0:成功 1:警告 2:错误 ----注意:确定警告的时候要做什么动作) , x_errbuf out varchar2 ---具体的错误信息 ); ---默认用上绑定变量的逻辑! procedure query2sheet(p_sql varchar2, p_column_headers boolean := true, p_directory varchar2 := null, p_filename varchar2 := null, p_sheet pls_integer := null, p_footer boolean := true, x_retcode out number ---0:成功 非0:失败( 或者:0:成功 1:警告 2:错误 ----注意:确定警告的时候要做什么动作) , x_errbuf out varchar2 ---具体的错误信息 ); ---最简单的使用版本 procedure query2sheet(p_sql varchar2, p_column_headers boolean := true, p_directory varchar2 := null, p_filename varchar2 := null, p_sheet pls_integer := null, p_footer boolean := true); ---参考老外的,另外封装的一个好用的过程!游标直接输出excel。未测试过~ procedure cursor2sheet(p_sql in sys_refcursor, p_column_headers boolean := true, p_directory varchar2 := null, p_filename varchar2 := null, p_sheet pls_integer := null, p_footer boolean := true); -- end;smt_xlsx_maker_pkg 包头部分
create or replace package body smt_xlsx_maker_pkg is -- c_local_file_header constant raw(4) := hextoraw(‘504B0304‘); -- Local file header signature c_end_of_central_directory constant raw(4) := hextoraw(‘504B0506‘); -- End of central directory signature -- type tp_xf_fmt is record( numfmtid pls_integer, fontid pls_integer, fillid pls_integer, borderid pls_integer, alignment tp_alignment); type tp_col_fmts is table of tp_xf_fmt index by pls_integer; type tp_row_fmts is table of tp_xf_fmt index by pls_integer; type tp_widths is table of number index by pls_integer; type tp_cell is record( value number, style varchar2(50)); type tp_cells is table of tp_cell index by pls_integer; type tp_rows is table of tp_cells index by pls_integer; type tp_autofilter is record( column_start pls_integer, column_end pls_integer, row_start pls_integer, row_end pls_integer); type tp_autofilters is table of tp_autofilter index by pls_integer; type tp_hyperlink is record( cell varchar2(10), url varchar2(1000)); type tp_hyperlinks is table of tp_hyperlink index by pls_integer; subtype tp_author is varchar2(32767 char); type tp_authors is table of pls_integer index by tp_author; authors tp_authors; type tp_comment is record( text varchar2(32767 char), author tp_author, row pls_integer, column pls_integer, width pls_integer, height pls_integer); type tp_comments is table of tp_comment index by pls_integer; type tp_mergecells is table of varchar2(21) index by pls_integer; type tp_validation is record( type varchar2(10), errorstyle varchar2(32), showinputmessage boolean, prompt varchar2(32767 char), title varchar2(32767 char), error_title varchar2(32767 char), error_txt varchar2(32767 char), showerrormessage boolean, formula1 varchar2(32767 char), formula2 varchar2(32767 char), allowblank boolean, sqref varchar2(32767 char)); type tp_validations is table of tp_validation index by pls_integer; type tp_sheet is record( rows tp_rows, widths tp_widths, name varchar2(100), freeze_rows pls_integer, freeze_cols pls_integer, autofilters tp_autofilters, hyperlinks tp_hyperlinks, col_fmts tp_col_fmts, row_fmts tp_row_fmts, comments tp_comments, mergecells tp_mergecells, validations tp_validations); type tp_sheets is table of tp_sheet index by pls_integer; type tp_numfmt is record( numfmtid pls_integer, formatcode varchar2(100)); type tp_numfmts is table of tp_numfmt index by pls_integer; type tp_fill is record( patterntype varchar2(30), fgrgb varchar2(8)); type tp_fills is table of tp_fill index by pls_integer; type tp_cellxfs is table of tp_xf_fmt index by pls_integer; type tp_font is record( name varchar2(100), family pls_integer, fontsize number, theme pls_integer, rgb varchar2(8), underline boolean, italic boolean, bold boolean); type tp_fonts is table of tp_font index by pls_integer; type tp_border is record( top varchar2(17), bottom varchar2(17), left varchar2(17), right varchar2(17)); type tp_borders is table of tp_border index by pls_integer; type tp_numfmtindexes is table of pls_integer index by pls_integer; type tp_strings is table of pls_integer index by varchar2(32767 char); type tp_str_ind is table of varchar2(32767 char) index by pls_integer; type tp_defined_name is record( name varchar2(32767 char), ref varchar2(32767 char), sheet pls_integer); type tp_defined_names is table of tp_defined_name index by pls_integer; type tp_book is record( sheets tp_sheets, strings tp_strings, str_ind tp_str_ind, str_cnt pls_integer := 0, fonts tp_fonts, fills tp_fills, borders tp_borders, numfmts tp_numfmts, cellxfs tp_cellxfs, numfmtindexes tp_numfmtindexes, defined_names tp_defined_names); workbook tp_book; lc_rows tp_rows; --new 2015.5.27 -- procedure debuglog(p_msg in varchar2) is begin if g_debug_type = ‘DBMS_OUTPUT‘ then dbms_output.put_line(p_msg); elsif g_debug_type = ‘FILE_OUTPUT‘ then --XYG_FND_FILE.PUT_LINE(FND_FILE.OUTPUT, P_MSG); null; elsif g_debug_type = ‘REQUEST_OUTPUT‘ then --LOG(P_MSG); --FND_FILE.PUT_LINE (FND_FILE.LOG, P_MSG); null; end if; end debuglog; procedure blob2file(p_blob blob, p_directory varchar2 := ‘MY_DIR‘, p_filename varchar2 := ‘my.xlsx‘) is t_fh utl_file.file_type; t_len pls_integer := 32767; begin t_fh := utl_file.fopen(p_directory, p_filename, ‘wb‘); for i in 0 .. trunc((dbms_lob.getlength(p_blob) - 1) / t_len) loop utl_file.put_raw(t_fh, dbms_lob.substr(p_blob, t_len, i * t_len + 1)); end loop; utl_file.fclose(t_fh); end; -- function raw2num(p_raw raw, p_len integer, p_pos integer) return number is begin return utl_raw.cast_to_binary_integer(utl_raw.substr(p_raw, p_pos, p_len), utl_raw.little_endian); end; -- function little_endian(p_big number, p_bytes pls_integer := 4) return raw is begin return utl_raw.substr(utl_raw.cast_from_binary_integer(p_big, utl_raw.little_endian), 1, p_bytes); end; -- function blob2num(p_blob blob, p_len integer, p_pos integer) return number is begin return utl_raw.cast_to_binary_integer(dbms_lob.substr(p_blob, p_len, p_pos), utl_raw.little_endian); end; -- procedure add1file(p_zipped_blob in out blob, p_name varchar2, p_content blob) is t_now date; t_blob blob; t_len integer; t_clen integer; t_crc32 raw(4) := hextoraw(‘00000000‘); t_compressed boolean := false; t_name raw(32767); begin t_now := sysdate; t_len := nvl(dbms_lob.getlength(p_content), 0); if t_len > 0 then t_blob := utl_compress.lz_compress(p_content); t_clen := dbms_lob.getlength(t_blob) - 18; t_compressed : var cpro_id = "u6292429";热心网友 时间:2022-04-08 21:31
oracle导出excel
一、oracle导出excel
方法一:最简单的方法---用工具plsql dev
执行File =>newReport Window 。在sql标签中写入需要的sql,点击执行或按快捷键F8,会先吃出查询结果。在右侧工具栏,可以选择按钮另存为html、copy as html、exportresults,其中export results按钮中就可以导出excel文件、csv文件、tsv文件、xml文件。
方法二:最专业的方法---用原始工具sqlplus
原文参见:http://www.eygle.com/archives/2005/04/eoasqlplusieaae.html
我做了一点修改,如下所示:
1.main.sql
用以设置环境,调用具体功能脚本
2.功能脚本-get_tables.sql
为实现具体功能之脚本
通过这样两个脚本可以避免spool中的冗余信息,参考:
如何去除SQLPLUS中SPOOL的冗余信息
示例如下:
1.main.sql脚本:
[oracle@jumper utl_file]$ more main.sql
set linesize 200
set term off verify off feedback off pagesize 999
set markup html on entmap ON spool on preformat off
spool d:/tables.xls
@d:/get_tables.sql
spool off
exit
2.get_tables.sql脚本:
[oracle@jumper utl_file]$ more get_tables.sql
select owner,table_name,tablespace_name,blocks,last_analyzed
from all_tables order by 1,2;
3.执行并获得输出:
[oracle@jumper utl_file]$ sqlplus "/ as sysdba" @d:/main.sql
SQL*Plus: Release 9.2.0.4.0 - Proction on Mon Apr 25 10:30:11 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Proction
With the Partitioning option
JServer Release 9.2.0.4.0 - Proction
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Proction
With the Partitioning option
JServer Release 9.2.0.4.0 - Proction
[oracle@jumper utl_file]$ ls -l tables.xls
-rw-r--r-- 1 oracle dba 69539 Apr 25 10:30 tables.xls
[oracle@jumper utl_file]$
此处输出为xls文件,通过下图我们可以看到输出效果:
把main.sql脚本中的,spooltables.xls更改为spool tables.htm,我们可以获得htm格式输出,效果如下图:
方法三:最悲剧的方法,之所以称为悲剧,是因为这个方法其实很简单,但是你可能没有注意。
打开plsql dev工具,执行file=>newsql window ,输入sql,点击工具栏“执行”按钮或按快捷键F8。会显示出结果集。
点击结果集的左上方,可全部选中结果集,然后右键=>copy,直接粘贴到excel文件中就可以了!
方法四:最努力的方法,这种方法稍微有点麻烦,但不用写脚本,也不用psql dev工具,只用sql plus就可以了。
在sqlplus中,执行想要的sql,把结果集copy到文本文件中(或者直接用spool命令直接输入到文本文件中),把不必要的字符、空格替换成逗号",",然后另存为csv文件,最后在用excel另存为exl文件就可以了。
二、把excel文件数据导入到oracle的某个表中。
方法一:最省时的方法,需要借助plsql dev工具。
a.复制整个工作簿中的数据到某个表中。
点击excel工作区左上角,全部选中数据,ctrl+c 复制整个工作簿中的数据。在plsql dev中,编辑表格表的数据,点击数据展示区左上角,直接粘贴就可以了(注意excel的第一列应该保持为空,如果不为空可以增加一空列,不然你复制的数据就会少一列的)!如下图
所示:
b.复制某列的数据。
这个很容易,选中excel某一列的数据,复制,选中oracle某个表的某一列,直接粘贴就可以了。plsql dev和excel中的列可以相互复制。
方法二:最专业的方法,用sql loader。
原文地址:http://daniel-wuz.javaeye.com/blog/198112
1.录入excel 测试表格,test.xls。
2.另存为.csv格式
3.创建sql*loader控制文件test.ctl,内容如下:
Load data
Infile 'c:/test.csv'
insert Into table test Fields terminated by','(column1,column2,column3,column4,column5)
需要将数据文件拷贝到对应位置
4.到数据库中建立对应的测试表test
create table test (
column1 Varchar2(10),
column2 Varchar2(10),
column3 Varchar2(10),
column4 Varchar2(10),
column5 Varchar2(10)
)
5.执行导入命令
Sqlldr userid = system/manager control='C:/test.ctl'
导入成功!
附:
Sqlldr的函数关键字说明:
Userid --oracle用户名 userid = username/password
Control --控制文件名称 control =‘e:/insert.ctl’
Log –-日志文件名称 log = ‘e:/insert.log’
Bad --损坏文件名称
Data --data file name
Discard --discard file name
Discardmax --number of discards to allow(默认全部)
Skip --导入时跳过的记录行数(默认0)
Load --导入时导入的记录行数(默认全部)
Errors --允许错误的记录行数(默认50)
ctl文件内容说明:
Load data
Infile ‘e:/test.csv’ --数据源文件名称
Append|insert|replace --append在表后追加,insert插入空表,replace替代原有内容
Into table test --要导入的数据库表名称
[when id = id_memo] --过滤条件
Fields terminated by X’09’ --字段分隔符
(id,name,telphone) --字段名称列表
方法三:最悲剧的方法,创建oracle外部表,为了把excel中的数据导入到数据中而去建立外部表,大题小做了!
将excel文件另存为csv文件a.csv,然后创建一个外部表t,数据指向a.csv。然后根据外部表创建一个普通的表:
create table a asselect * from t ,这样就可以把最初的excel文件导入到oracle中的表了。
方法四:最古典的方法,拼接sql语句。如果你excel熟的话,这种方法也不错。
在excel中,把数据拼接成如下sql语句:
insert into empvalues('1','2','3');
insert into empvalues('4','5','6');
insert into empvalues('7','8','9');
copy 出以上sql,执行就可以了!!热心网友 时间:2022-04-08 22:49
如果是oracle sql developer的话,在查询结果哪儿,用右键,可以导出成excel的。
如果用pl/sql developer、toad之类的,也可以将查询结果导出成excel
pl/sql developer还可以直接copy查询结果,到excel中粘贴。
如果用navicat for oracle,可以使用导出的方法。热心网友 时间:2022-04-09 00:23
可以直接用SQL Navicat 这个第三方工具来生成即可~~