Hi,
How can I export some tables from Postgres to SQL scripts? I've tried the COPY...TO command but it's not really what I was looking for as it creates CSV files.
Cheers,
Matt
7 5070
It does not have to be a CSV, the COPY command allows you to specify any delimiter you want.
I'm not sure though what you mean by "copy to SQL scripts"
It may help if you elaborate on what output format you're trying to create, and how you intend to use it.
I'm trying to get a .sql output, which in turn I want to convert to a shapefile (.shp).
I'm trying to get a .sql output, which in turn I want to convert to a shapefile (.shp).
Sorry, but this does not tell me anything.
.sql is just an extension, which does not necessarily imply any specific standard or format, it only suggests that this file probably contains sql commands.
What you really need is to identify the exact format of what you call an .sql file.
Sorry for being a bit vague, I hadn't realised there were various types of SQL files. I checked the files and they're 'Microsoft server SQL query files'- does that help? Below I've copied a the text from the header and footer of a file similar to what I'd like to output.
Thanks -
BEGIN;
-
CREATE TABLE "txt_barrio" (gid serial PRIMARY KEY,
-
"nombre" varchar(254),
-
"izena" varchar(254),
-
"text_angle" float8,
-
"text_size" float8,
-
"textstring" varchar(254));
-
SELECT AddGeometryColumn('','txt_barrio','the_geom','23030','POINT',2);
-
INSERT INTO "txt_barrio" ("nombre","izena","text_angle","text_size","textstring",the_geom) VALUES ('Poligono Industrial La Coba','La Coba industrialdea','0.000000','31.123845','La Coba industrialdea / Poligono Industrial La Coba','SRID=23030;0101000000316948FDC0F01E415D47207DAC095241');
-
.....
-
.....;
-
END;
-
Thanks for clarification.
You need to look at pg_dump utility.
Give it a try, make sure to use the desired command line parameters.
I assume you want to dump data in a plain text format and probably want to use INSERT instead of COPY.
Thanks for the link. Although I managed to solve the problem just before going to lunch. A friend passed me a BAT file called postgistoshp.bat, which works, although I'm not sure how(!).
This is the code: -
-
rem %1 database - %2 table
-
pgsql2shp.exe -h <server_name> -u postgres <DB_name> <table_name>
-
Cheers,
Matt
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sridevi |
last post by:
Hello
How to export data from ms-access database to excel worksheet using ASP.
mainly i need to export data to multiple worksheets. it is very urgent to
us.
i have a sample code which works...
|
by: btober |
last post by:
Whenever I create a temporary table, with something like
CREATE TEMPORARY TABLE temptable1 AS SELECT * FROM paid.ad_hoc_query;
New schemas appear, with names like "pg_temp_1". I guess the...
|
by: Martin_Hurst |
last post by:
Is it possible to establish a connection from within a postgres database to
another external database on the network, i.e., not a java or scripting
connection, BUT by some type of table definition...
|
by: Ati Rosselet |
last post by:
I have several tables with common FKs.. the problem occurs when
performing a large number of inserts on any of the tables at the same
time. The first to start inserting seems to get a lock on the...
|
by: Jared Carr |
last post by:
First I wish I knew how this was caused but here is our problem.
Sometime in the recent past we got a duplicate table. Here is the
result of a pg_dump with a pg_restore for just that table.
...
|
by: pgmoscatt |
last post by:
I have just moved over to PostGres after using MySQL.
In MySQL I could issue the command SHOW TABLES within a database to show
what tables are within.
I tried to do this with PostGres and I...
|
by: Prabu Subroto |
last post by:
Dear my friends...
I am using SuSE Linux 9.1 and postgres. I am a
beginner in postgres, usually I use MySQL.
I have 3 tables : appointment, appointment0 and
appointment1.
the fields of...
|
by: Snozz |
last post by:
The short of it:
If you needed to import a CSV file of a certain structure on a regular
basis(say 32 csv files, each to one a table in 32 databases), what
would be your first instinct on how to...
|
by: jjwiet |
last post by:
Hello,
I use access 2003 and attempting to export/copy records between two access databases (almost identical) with multiple tables (both databases having the same relations between the tables)....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
| |