一颗秋天的树
梦有多远,路就有多远......
posts - 15,comments - 20,trackbacks - 0

在项目开发过程中,客户往往要要将其使用的 excel 存储的数据导入到其它数据库中,下面的工作主要是将 excel 导入各种数据库的汇总
准备:在数据库中创建从 excel 要导入的表结构;

一、 excel 导入 db2 的各种方法 
1 :使用文本方式导入
1
)、将 access 导出具有标准格式符的文本文件,例如以逗号分隔的文本文件
2
)、在 db2 的命令行处理器中,连接上数据库,用 import     语句导入,语句如下:       
 import   from   table.txt   of   del   modified   by   coldel
   insert   into   table 
同理,导出命令: 
export   to   table.txt   of   del   modified   by   coldel
   select   *   from   table
2:使用csv文件 方式导入          
 1
)、把excel文件另存为table.csv文件  
2
)、在db2的命令行处理器中,连接上数据库,用import     语句导入
  import   from   "d:\table.csv"   OF   DEL   messages   "d:\msg.out"     INSERT   INTO   table

二、 excel 导入 oracle 的各种方法
1 、与 db2 导入方法相同
2 、使用 sqlldr 装载数据:
1 )、先把 Excel 另存为 .csv 格式文件,以逗号数据字段分隔的文本文件,如 table.csv
2 )、编写一个 insert.ctl ,用 sqlldr 进行导入 !
insert.ctl
内容如下:
load data
infile 'table.csv'
append into table tableName
fields terminated by ','
(field1,field2,field3,...fieldn)
3
)、执行命令: sqlldr user/password control=insert.ctl
3 、使用 PL/SQL
  如果你的单个文件不大全选 COPY , PL/SQL Developer 运行 SQL 语句 select * from table for update 或者在左侧树形菜单中选中相应的表格,点击右键,在弹出式菜单中点击 "Edit Data". 然后打开表格数据上方的锁 , 再按一下加号 , 添加一行新空行 . 鼠标点到第一个空格然后粘贴 . COMMIT 即可 .

 

posted on 2006-11-22 14:04 sojust 阅读(3295) 评论(1)  编辑  收藏 所属分类: DataBase

FeedBack:
# re: 从Excel导出数据到数据库中
2007-11-08 15:16 | Noriko
你好
我导入到Oracle时候报错,帮我看看好吗
谢谢啦
<A HREF=http://p15.freep.cn/p.aspx?u=v20_p15_p_0711081513506174_0.jpg&click=1 TARGET=_BLANK><IMG SRC=http://p15.freep.cn/p.aspx?u=v20_p15_p_0711081513506174_0.jpg></A>  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
    梦有多远,路就有多远......