Skip site navigation (1) Skip section navigation (2)

Re: convert text file to database

From: e-letter <inpost(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: convert text file to database
Date: 2008-04-22 08:36:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
i think you want convert text file to database. You can use COPY
command and you can add a column whose value is id number such as
1,2, can set the column is series type or you can first create
a sequence and set default value of new column be sequence .

SQL is :

1. ALTER TABLE xxxxx

 ADD COLUMN id series;


CREATE SEQUENCE  public. mile_danxianhe_gid_seq


    MAXVALUE 9223372036854775807  START 1


ALTER TABLE public.yantian_2006_mile

ADD COLUMN id integer DEFAULT nextval('mile_danxianhe_gid_seq'::regclass);

wish you can understand my explain.

best regard.


----- Original Message -----
From: e-letter <inpost(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: [NOVICE] convert text file to database
Date: 08-04-21 22:52:40

I amended a copy of my csv files as follows


Compared to my original csv file, I had to remove the field names that
were in the csv file (e.g. event,onlinegame,site,www...,date,yyyy....

I also had to remove all full stop (.) characters, such as in the url
name and within the list of moves (e.g. 1. e4 d7 2. gf3...). Instead
of removing the full stops, could I have prefixed the character with
the backstroke (\), e.g. to become www\.flyordie\.com? The user guide
says so but when I tried the csv file import failed.

Moreover, I had to add an id number to represent the id primary key,
as the first column of data. I thought there would be a way to
automatically add this column to the csv file?

Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
To make changes to your subscription:

 想玩得精彩?快来惠普"我的电脑 我的舞台"(


pgsql-novice by date

Next:From: Andrej Ricnik-BayDate: 2008-04-22 09:36:50
Subject: Re: Remote / network connection fails
Previous:From: e-letterDate: 2008-04-21 14:52:40
Subject: Re: convert text file to database

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group