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博客 ” ,链接:https://blog.itpub.net/29898569/viewspace-1789509/
,如需转载,请注明出处,否则将追究法律责任。