Given a redis instance containing two databases db1, db2:
Is it possible to query if k1 \in db1 and k2 \in db2 in one transaction, i.e., a single request from the client?
Yes, that is possible if you use a Lua script.
Related
I have 3 databases hosted across 3 different servers, all of which have different data and structures. I need to perform a query that will draw data from various tables across all three of them.
I've registered the three servers into a server group, and I've confirmed that all of the connections are working properly.
Here's an example of the problem I'm facing. For the first part of this query, I need to retrieve a list of records from the 'Applications' table in DB1 so I write:
SELECT * FROM [DB1].[dbo].[Application]
I know that this query works partially because it starts returning results from the correct table. The problem is that I haven't specified the server that DB1 is on, so once the query has finished querying DB1.dbo.Application, it looks for the same database and table on the next server. The database and table don't exist on the other servers so the query fails.
So how do I specify the server that I want the query to run on? I've tried [server_name].[DB1].[dbo].[Application], but it still runs the query across all of them.
Server groups are for maintenance purposes, what you need to use is a linked server
On one of the servers, say SERVER1, you will need to set up two linked servers - one to SERVER2 and one to SERVER3
From SERVER1 you will then be able to query the other servers using the four part name in a normal query window:
SELECT * FROM DatabaseName.dbo.Table1;
SELECT * FROM SERVER2.DatabaseName.dbo.Table2;
SELECT * FROM SERVER3.DatabaseName.dbo.Table3;
You can also use the tables from the remote server in JOINs etc as though they were on the local server and the remote servers don't even need to run SQL Server - they can be Oracle, MYSQL etc.
Be aware though, remote servers are slow and you may struggle with large datasets
How can I move the data from all fields (*) and all tables from db1 to db2 with Oracle ?
You have two choices:
use exp and imp (or, if using 10g or later, expdp and impdp);
use a database link.
As you don't tell much about your environment etc, this is as close an answer as it gets...
I have 2 databases and want to implement triggers on table update of database1 to do do some updates on database2's tables.
Example:
db1 has a table 1t1
db2 has a table 2t1
on inserting a touple into 1t1 i want to insert corresponding touple into 2t1
As of now Im using postgresql, but I dont mind switching to other free databases.
How to achieve this?
I suggest to use database link to establish a connection between two remote DB.
Take a look to this page:
http://www.postgresql.org/docs/current/static/contrib-dblink-connect.html
There is also a good tutorial here:
http://www.postgresonline.com/journal/archives/44-Using-DbLink-to-access-other-PostgreSQL-Databases-and-Servers.html
bye,
Andrea
If you could replace databases with schemas everything becomes easy.
Possibility of such replacement depends on why you have chosen databases as organisational units.
Postgresql 9.1 has a new feature called "foreign table":
http://www.postgresql.org/docs/9.1/static/sql-createforeigntable.html
Does that help maybe?
All, is there any means by which it is possible to connect to two separate MySQL databases and execute SQL statements to interact with both?
The aim would be to query DB 1 on connection 1 and insert the results into DB 2 on connection 2.
Is it possible to do this using the MySQL query browser?
I suppose there are two ways how to do this.
the first is manual : DB dump : " SELECT * INTO OUTFILE 'authors090308.sql' FROM authors; " and then "LOAD DATA INFILE 'authors090308.sql' INTO TABLE authors;" (you also need to specify some other parameters as to delimiting columns etc.) or by some other "database dump", where data goes into file the way you want. In between you must switch database manually to the second one.
the second is programmatic : with programming language : Then you need to just open two connections to the databases and realize the statements you need. I don't know if it is what you mean, you'd need to be more specific.
Anyway, you need a connection to a DB server, either via mysql client, oracle sql developer, mysql workbench or via mysql adapter/driver of a programming language. What you need, is the "glue" between 2 connections, which is the programming language. It's either a programming language or a file data is dumped into and back again.
I'm sorry but I don't thing there are any other ways of doing this...as to the first way, you can only get the output from a database and either use mysql pager and pipe the output somewhere (a file perhaps), or SELECT * INTO OUTFILE, mysqldump, mysqlhotcopy etc.
is there a way to create a select statement that would retrieve data from multiple database in postgre?
i was thinking it would be something like this:
select * from dbname1.table1, dbname2.table2 where dbname1.table1.column1 = dbname2.table2.column1
Have a look at the "dblink" contrib module.
OTOH it's possible that you treat the databases in a PostgreSQL cluster as equivalent to the databases in... let's say MySQL. Which is incorrect - the PostgreSQL databases contain schemas and those are the equivalent of the databases in MySQL.
From here:
It is not possible to access more than
one database per connection.
Update: but see Milen's answer.