将Excel数据导入PostgreSQL 9.3 [英] Import Excel Data into PostgreSQL 9.3

查看:113
本文介绍了将Excel数据导入PostgreSQL 9.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个excel表,现在面临的问题,将其转换到postgresql数据库。我已经下载了odbc软件,我可以打开使用excel在postgresql中创建的表。但是,我无法以相反的方式执行此操作,即在excel中创建表并在postgresql中打开它。所以我想知道这是可以这样做的,还是有任何其他方法可以用pgAdmin III创建一个大的表,因为原始的原始数据被插入是非常乏味的。



提前感谢所有的帮助!

解决方案

典型的答案是这样的:


  1. 在Excel中,文件/另存为,选择CSV,保存当前工作表。


  2. 转到Pg服务器上的postgres用户可以访问的保存目录


  3. 在PostgreSQL中:



    COPY mytable FROM'/ path / to / csv / file'WITH CSV HEADER;

      - 必须是超级用户


但还有其他这样做也是如此。 PostgreSQL是一个令人惊讶的可编程数据库。这些包括:


  1. 在pl / javaU,pl / perlU或其他不受信任的语言中编写一个模块来访问文件,解析它,并管理结构。


  2. 使用CSV和fdw_file作为伪表访问它


  3. 使用DBILink和DBD :: Excel


  4. 编写您自己的外部数据包装器以阅读Excel文件。


可能性是无止境的....


I've developed a huge table in excel and now facing problem in transferring it into the postgresql database. I've downloaded the odbc software and I'm able to open table created in postgresql with excel. However, I'm not able to do it in a reverse manner which is creating a table in excel and open it in the postgresql. So I would like to know it is can be done in this way or is there any alternative ways that can create a large table with pgAdmin III cause inserting the data raw by raw is quite tedious.

Thanks in advance for all the helps!

解决方案

the typical answer is this:

  1. In Excel, File/Save As, select CSV, save your current sheet.

  2. transfer to a holding directory on the Pg server the postgres user can access

  3. in PostgreSQL:

    COPY mytable FROM '/path/to/csv/file' WITH CSV HEADER; -- must be superuser
    

But there are other ways to do this too. PostgreSQL is an amazingly programmable database. These include:

  1. Write a module in pl/javaU, pl/perlU, or other untrusted language to access file, parse it, and manage the structure.

  2. Use CSV and the fdw_file to access it as a pseudo-table

  3. Use DBILink and DBD::Excel

  4. Write your own foreign data wrapper for reading Excel files.

The possibilities are literally endless....

这篇关于将Excel数据导入PostgreSQL 9.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆