Can we create a database on remote machine in postgresql DB, if yes then how?
Yes. Assuming the remote server is Linux, and assuming you have sudo or root privileges on that server, you could SSH into the remote server and use a package manager (like yum, synaptic, or apt) to install the PostgreSQL server.
You can configure it using vi (or emacs or other text editor). Usually, the files you edit are found in the /var/lib/pgsql/data folder, and an /etc/init.d/postgresql startup script for whenever the server reboots. You'll usually need to edit the pg_hba.conf file to allow a connection from your client's subnet. That part can be troublesome if overlooked.
You'll be able to initially run psql as the postgres user, and can create datatabases, run scripts, etc from the command line. Once you allow a remote connection, you can do the same from the comfort of your own gui, such as PgAdminIII or any Java-based database manager that can use a JDBC connector.
Example:
psql -U postgres
create database foo;
\q
First, get your programming language. Let say it's PHP to make it simple.
Second, you get the PostGresql connector. Here is the link for PHP but you can get for all popular language.
Third, you open a connection and you do the command you want. You want to create a database so you call the create database YourDatabaseName command.
Related
I want to connect to remote oracle DB using pro*c in C program.
I am able to connect to the DB using oracle sql developer using,
UserId : ABCD
Password: abcd
HostIP(Name): 123.45.67.890 (Qwerty)
Service Name: Asd03
Also Can someone share references on how to do it ?
I don't want to install oracle in my system (due to space constraints), Can it be done using oracle instant-client modules?
Yes, this can be done using the instant client.
To make debugging your installation easier I advice to also install the sqlplus client.
First get your sqlplus client connected. (This will learn you how to set ORACLE_HOME and path)
Next, with the setting from step 1, try to connect your pro*c client.
Is there a way to load a PostgreSQL DB dump file to a remote SQL Server database? Eg. is there a way BCP could do this or anything in the mssql-tools package?
I have a database in a PostgreSQL DBMS that I am periodically creating a dump file for like...
sudo -u postgres pg_dump --format=custom -d mydb > mydb.dump
...and can move it into a NFS or FTP mount which is also mounted on a centralized data movement server (basically I run an Airflow instance here for managing scheduling). From here I can connect to another server hosting a SQL Server instance. I would like to import this dump file into a DB on the SQL Server remotely (ie. running code and scheduling from the data movement server) (normally I write large tables to this SQL Server instance via the bcp utility from mssql-tools, but not sure how to handle this dump file). I have access credentials to the MSSQL DB, but can't install any new applications, code, etc on the server.
Rarely deal w/ DB stuff. Anyone know if this is possible (or if there is a better / more conventional way to do this kind of thing)?
I need to connect to a remote database (Oracle) using a MS SQL Server (2019) linked server. What I did so far:
Installed Oracle Instant Client x64 and the ODBC drivers on the machine where the SQL server is running
Created a symlink to the central TNSNAMES.ORA (on a file share in the network) inside the Oracle Instant client folder.
Set the necessary environment variables
Created an ODBC connection to the database on the Oracle server on this machine
Restarted MS SQL Server
Created a linked server (Microsoft OLEDB Provider for ODBC Drivers) in the SQL instance
When connecting to the SQL Server using sqlcmd on this machine (I did not install SSMS there), I can query the linked database using OPENQUERY(). I can also read the file TNSNAMES.ORA using this command (note, the given file is the symlink, but it displays the contents of the linked file, as it should):
SELECT * FROM OPENROWSET(BULK 'C:\InstantClientx64\tnsnames.ora', SINGLE_CLOB) TNSNames
So far, everything is fine.
Now, when I connect to the SQL Server from my workstation using SSMS, i get the following error when trying to read TNSNAMES.ORA using the command above:
Cannot bulk load because the file "C:\InstantClientx64\tnsnames.ora" could not be opened. Operating system error code 5(Access is denied.).
I created a file test.txt in the instant client folder containing something like "Am I allowed to read this?" - and I was, no problems.
I started procmon on the server to find out what happens. When using the above command on the SQL server, I get a REPARSE (because it's a link!), and then SUCCESS, the file is displayed in the sqlcmd console.
When using this command in SSMS (on my local workstation), first appears the REPARSE (OK), then ACCESS DENIED.
In both cases it is the same user account which is displayed as "Impersonating" in the procmon's details. There is definitely no problem with a firewall, and the read permissions on the tnsnames.ora file on the network share are granted for Everyone. I am also able to create an ODBC item on the local workstation, and can connect and query the database from here.
I have done this in the past I don't know how often, and never had problems. What am I missing?
Why are you trying to read the tnsnames.ora file via SQL? The Oracle libraries will (should) internally open it and use it when your app connects to the DB.
The default location for network config files is shown in the Instant Client installation doc. In your case it will be C:\InstantClientx64\network\admin. Unless you have set the TNS_ADMIN variable, then start by creating this subdirectory and putting tnsnames.ora in it.
(A future version of Instant Client on Windows will create the network\admin subdirectory automatically, similar to the way it is created with the Linux Instant Client packages).
As I knew, Oracle Instant Client is free from OTN for anyone to use in a development or production environment. But in order to create a ODBC data source on windows, i need a tns service name? How can I create odbc data source on windows os by using oracle instant client?
Check the ODBC installation instructions http://www.oracle.com/technetwork/database/features/oci/odbc-ic-releasenotes-094306.html :
On Windows
Install the Instant Client Basic or Basic Light package.
Download the Instant Client ODBC package. Unzip it
in the same directory as your Basic or Basic Light package.
Execute
odbc_install.exe from the Instant Client directory. If Instant
Client is 11g or lower, start the command prompt with the
Administrator privilege.
On Linux I sometimes hand edit my .odbc.ini file to change the TNS connect string in the ServerName field, for example to set it with the 'Easy Connect' TNS syntax:
ServerName = localhost/orclpdb
I have psql installed on my mac. The databases on psql and pgadmin are different and I can't seem to connect them to each other. I would like to be able to create a database and table in psql and have it also available in pgadmin but unable to so far. I tried google and stackoverflow with no success.
The psql shell on my mac is version is 10.4
The pgadmin gui on my mac is version 3.0
Is there any way that these two can be connected to each other so I can manipulate database with either?
I've created a database on pgadmin using the GUI and/or through jupyter notebook via sqlalchemy but it doesn't show up on psql. I've created a database and table on psql but it doesn't show up on pgadmin.
Not sure what I'm doing wrong? Tried to google to see if I can connect to pgadmin from psql but couldn't find anything.
Let me know what I'm doing wrong and how I can connect those two. Thanks
So, you've got two postgresql installs one version 9.6 as a system install and one 10.4 as a user install.
The system install is on port 5432 which is the default port number, so there's something overriding the psql connection so that it finds the version 10.4.
There should be a psql somewhere that came with the 9.6 install.
if you run that one it should connect you to the 9.6.
if that was the enterprisedb installer it looks like
/Library/PostgreSQL/9.6/psql
might be the one you need.
perhaps some mac-os guru can fill in the blanks like how to set the search path to find that psql first.