SpatialDB Advisor
|
Current PostGIS Blog Articles • Morton key function for PostgreSQL/PostGIS • Generating a Grid (fishnet) of points or polygons for PostGIS • ST_Parallel for PostGIS • R based Delaunay Triangulation Function for PostGIS using the deldir package • COGO: Converting Decimal Degrees to Degrees Minutes and Seconds - and back again (PostGIS) • COGO: Finding centre and radius of a curve defined by three points (PostGIS) • Gridding a geometry object (PostGIS) • FOSSLIC - PostGIS presentations • Vectorization: Exploding a linestring or polygon into individual vectors in PostGIS • How to apply spatial constraints to PostGIS tables • Loading and Processing GPX 1.1 files using PostgreSQL XML • Converting Oracle Optimized Rectangles to PostGIS • Building polygons from overlapping linestrings requiring intersection • Loading Point Data from a CSV File in PostGIS • DMS2DD for PostGIS • Implementing Oracle's GetVertices function in PostGIS - ST_DumpPoints • Filtering Rings in Polygon (PostGIS)
|
I recently wrote an article on the use of External File with Oracle tables to load point data into Oracle. I thought I would have a look on how to do this in PostGIS. A bit of research came up with the PostgreSQL COPY SQL command. There appears to be no equivalent to Oracle’s Organisation External for a table. In PostgreSQL you simply create your table and then insert data into it from an external file. You don’t seem to need to concern yourself with special permissions to do this: just get in and do it. Which is what we will do right now.
Now, that was pretty simple. There are certainly advantages to the PostgreSQL way of loading CSV organised data. I am not sure about the lack of security with regards to external file access though. One thing in Oracle’s favour is that externally organised tables can be used without having to load the data which can be useful in many situations. Anyway, I hope this article is of use to someone. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]()
![]() |
Comment [4]
I haven’t played with copy much but this is what I recall. I’ll have to verify my assumptions.
I wouldn’t say there is a lack of security for PostgreSQL, but it is probably not as fine grained as Oracle.
1) As I recall, you can only copy from directories where the service account PostgreSQL is running under has rights to the folder. Since PostgreSQL should never run as root and even refuses to run under Administrator in windows — this is not so much of an issue.
It just so happens that the C:\Temp folder has security set to everyone.
2) Also have to verify, but I think only super admins in Postgres can use the copy command. I should know this, but I’m not sure if you can even assign copy rights to non-super users. So if you wanted to copy under another account, you would have to create a stored function that does the copy and set it to run as SECURITY DEFINER. Then it would run under the context of the owner of the stored function and if that stored function is owned by a super user then it would work.
— Regina · 22 February 2009, 16:34 · #
Thanks a lot for that, it did help me a lot!
— Johannes · 5 December 2009, 01:19 · #
Thanks – very helpful. Note there have been some shifts in the COPY command’s syntax (though it should be backwards compatible). Also, if any of the field names or the table name begins with (possibly simply contain) a capital letter, strange effects can happen at the COPY step (e.g. errors to say that a Relation is not available (with the given table’s name).
— Jeremy Morley · 21 February 2012, 08:18 · #
I was worried, was solved in this article.
Thank you
From Japan
— nao · 6 April 2012, 12:49 · #