excel导入postgre

1先把excel另存为csv格式
2在postgresql建表
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE company (
    id bigint NOT NULL,
    name text,
    address text,
    owner text,
    telephone text,
    regtime text,
    filename text,
    mail text,
    celphone text,
    fax text,
    postcode text,
    product text,
    money text,
    business text,
    type text,
    income text,
    qq text,
    people text
);
CREATE SEQUENCE company_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;
ALTER SEQUENCE company_id_seq OWNED BY company.id;
ALTER TABLE ONLY company ALTER COLUMN id SET DEFAULT nextval('company_id_seq'::regclass);
ALTER TABLE ONLY company
    ADD CONSTRAINT test2_pkey PRIMARY KEY (id)
4 用copy导入

postgres=# copy
company(name,address,celphone,owner,type,deadline)
from '/data/tmp/厦门天天网络科技有限公司_utf8/深圳2015-416-226064.csv.txt' with csv header;
COPY 4424
postgres=# update company set filename = '厦门天天网络科技有限公司_深圳2015-416-226064' where filename is null;
UPDATE 4424

vim的查找与替换
:%s/,$//g b
把段尾的,号全部变成空格

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29898569/viewspace-1789509/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29898569/viewspace-1789509/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值