473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

COPY, \copy with defaults

CSN
I guess this is a feature request since I can't figure
out a way to do it directly in postgresql (plus
COPY/\copy isn't in SQL specs). Often when I import
data I need to assign foreign key id's, timestamps,
etc. How about a syntax something like:

\copy tablename (col1, col2, col3, fkid=8,
ts1='2004-8-8') from 'data.csv'

or maybe add a defaults clause after "with":

\copy tablename (col1, col2, col3) from 'data.csv'
with defaults (fkid=8,ts1='2004-8-8')

Or if anybody knows of a better/existing way please
feel free. :)

CSN

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
2 989
CSN <co*******************@yahoo.com> writes:
I guess this is a feature request since I can't figure
out a way to do it directly in postgresql (plus
COPY/\copy isn't in SQL specs).


You do know that COPY uses the column defaults for all columns not
listed in the input list?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #2
CSN
--- Tom Lane <tg*@sss.pgh.pa.us> wrote:
CSN <co*******************@yahoo.com> writes:
I guess this is a feature request since I can't

figure
out a way to do it directly in postgresql (plus
COPY/\copy isn't in SQL specs).


You do know that COPY uses the column defaults for
all columns not
listed in the input list?


Yep, but that won't work (foreign key id's, timestamps
other than now(), ...)

CSN

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: louis n | last post by:
I work with databases and some of my backup files are 30-100 gigs in size. I currently use the FastCopy utility to copy files from one server to another. (This is needed when I need to transfer a...
10
by: serge | last post by:
I am doing a little research on Google about this topic and I ran into this thread: ...
8
by: btober | last post by:
I'm finding that column defaults are not being assigned to nulls when I do an insert by way of a an ON INSERT rule on a view. For example, the following script \set ON_ERROR_STOP ON \c...
2
by: Toby Doig | last post by:
When I try to import data from a unicode file into PostgreSQL 7.4 under FreeBSD it appears to now understand the Unicode file format. To demonstrate I export a set of Integers into a Unicode file...
8
by: rKrishna | last post by:
I was trying to understand the real need for copy constructors. From literature, the main reason for redfinition of copy constructor in a program is to allow deep copying; meaning ability to make...
2
by: Tomas | last post by:
Hi, I am a VB.NET newbie that would like to know the best practise when working with objects and undo user changes to objects properties. Problem The system allows the user to change...
19
by: Jeroen | last post by:
Hi guys, I have a simple question. If I have a class like: class A { A(); ~A(); A(A& a); A(int i);
9
by: toton | last post by:
I have a class like template<typename T> class my_class{ public: int x_; public: template<typename U> my_class(const my_class<U>& other ) : x_(other.x_){} };
5
by: jgscott | last post by:
I've been trawling around for an answer to this question and thought I'd try here. I have a class Graph, which has a std::list<Nodeas a class member. Node it itself a class that makes extensive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.