Postgres EDB Run a sequence of sql files - postgresql

I'm attempting to run a sequence of SQL files using PEM. From the Oracle database I used:
#path_to_file1.sql
#path_to_file2.sql
#path_to_file3.sql
How do I do this using Postgres Enterprise Manager (PEM) ?
Please note that i'm NOT USING a command line and I don't want to run a SINGLE file, but I'm using PEM on a windows machine to run a SEQUENCE of sql files in one shot.
Regards.

Related

Connect Oracle database with SQLcl

I am using sqldeveloper to query database and export results to csv file. I need this file on daily basis so thought of creating bat file which can be scheduled on windows task scheduler. I was researching it and found I can use SQLcl to run my script to export the query data. But somehow I can't connect it and it gives me and error 'ORA-01017: invalid username/password;logon denied. Here is my connection properties from sql developer
Here is my command line:
sql testuser1/mypass#tstwd2.myhost.internal:1521/tst.internal
I have java development kit installed
Do I need anything for java? Or do I need any special rights to run sql command line?
Found the problem, my userid is in double quotes so I have to use escape sequence **\**, its working like a charm.

Postgres and data folder changing on Windows

It is possible to change postgres data folder during its installation on Windows? For example run the postgres instalator with some parameter.
At this time Iam using this procedure: https://wiki.postgresql.org/wiki/Change_the_default_PGDATA_directory_on_Windows
Or is there another script which do that?

Postgresql-postgis dynamic library path

I am trying to create a function in PostgreSql installed on a server but when a run the .sql function this is the error i get using PgAdminIII SQL queries:
ERROR: could not access file "$libdir/librouting_dd": No such file or
directory
I have read the 'dynamic_library_path (string)' in PostgreSql webpage but i don't understand how to write the correct path into my ubuntu system for PostgreSql.
Thanks in advance.

Can PostgreSQL COPY read CSV from a remote location?

I've been using JDBC with a local Postgres DB to copy data from CSV files into the database with the Postgres COPY command. I use Java to parse the existing CSV file into a CSV format matches the tables in the DB. I then save this parsed CSV to my local disk. I then have JDBC execute a COPY command using the parsed CSV to my local DB. Everything works as expected.
Now I'm trying to perform the same process on a Postgres DB on a remote server using JDBC. However, when JDBC tries to execute the COPY I get
org.postgresql.util.PSQLException: ERROR: could not open file "C:\data\datafile.csv" for reading: No such file or directory
Am I correct in understanding that the COPY command tells the DB to look locally for this file? I.E. the remote server is looking on its C: drive (doesn't exist).
If this is the case, is there anyway to indicate to the copy command to look on my computer rather than "locally" on the remote machine? Reading through the copy documentation I didn't find anything that indicated this functionality.
If the functionality doesn't exist, I'm thinking of just populating the whole database locally then copying to database to the remote server but just wanted to check that I wasn't missing anything.
Thanks for your help.
Create your sql file as follows on your client machine
COPY testtable (column1, c2, c3) FROM STDIN WITH CSV;
1,2,3
4,5,6
\.
Then execute, on your client
psql -U postgres -f /mylocaldrive/copy.sql -h remoteserver.example.com
If you use JDBC, the best solution for you is to use the PostgreSQL COPY API
http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html
Otherwise (as already noted by others) you can use \copy from psql which allows accessing the local files on the client machine
To my knowledge, the COPY command can only be used to read locally (either from stdin or from file) from the machine where the database is running.
You could make a shell script where you run you the java conversion, then use psql to do a \copy command, which reads from a file on the client machine.

Backup Oracle 10g Database from Windows Server 2003 R2 on which command line is disabled

I need to backup Oracle 10g Database from Windows Server 2003 R2 where command line is disabled by some virus problem. RMAN and other graphical utilities are also not working. Only possible thing is that I could take OS file backup of the running database (it can't be stopped also). I do have a trace control file of the database. Please provide some solution so that I could restore the database to a new server.
You can create a backup using Oracle DataPump through SQL:
http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_datpmp.htm
Here are some examples how to use it:
http://psoug.org/reference/dbms_datapump.html
http://jhdba.wordpress.com/2009/05/06/237/