excel 导入各种数据库的汇总

来源:互联网 发布:故宫淘宝和故宫文创 编辑:程序博客网 时间:2024/05/17 04:49
在项目开发过程中,客户往往要要将其使用的 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 即可 .
 ——向老余同志学习。
 
原创粉丝点击