0
I use the following query to select data from one database and insert into another:
insert into banco_novo.cliente (codcliente, nome, cpf, rg, sexo, data_nascimento, endereco, bairro, cidade, estado, cep)
select codcliente, nome, cpf, rg, IFNULL(sexo, 'I'), IFNULL(data_nascimento, '2000-01-01'), endereco, bairro, cidade, IFNULL(estado, '0'), cep
from banco_antigo.cliente
I now need to select a database on one server and insert it into another database on another server.
I tried so:
insert into servidor_novo.banco_novo.cliente (codcliente, nome, cpf, rg, sexo, data_nascimento, endereco, bairro, cidade, estado, cep)
select codcliente, nome, cpf, rg, IFNULL(sexo, 'I'), IFNULL(data_nascimento, '2000-01-01'), endereco, bairro, cidade, IFNULL(estado, '0'), cep
from servidor_antigo.banco_antigo.cliente
But to no avail.
I have Workbench connected with both servers, but I do not know how to execute the query to do this operation.
Tried to
INSERT INTO bancox.tabela (SELECT * FROM bancoy.tabela)
?– rbz
Two banks on the same server is OK. But two banks on two different servers that is BO
– Pedro Augusto
Now that I understand. I understand 2 banks, not 2 banks on separate servers.
– rbz
For different servers will not work directly. You will have to extract the
inserts
and run on the other connection.– Roberto de Campos
Will be?
– rbz
If you want to run queries on different Databases, it would not be the case to just use the "use database1" clause and then "use database2". before the honey that will spin?
– Rafael Salomão
@Rafaelsalomão In a query only I can do this ?
– Pedro Augusto
@Rafaelsalomão, what he needs is different servers and not just different banks.
– Roberto de Campos
Is it because I don’t get it, it’s two Databases on the same server ? Or two distinct banks one on each server ? Ahhhhhhhhhhhhhh
– Rafael Salomão
In this case on different servers would have to have two different connections!
– Rafael Salomão
@Rbz, never used this
link
, whenever I needed to do something similar, I did it via Excel or extracting theinserts
, but it seems to be a way out, I’ll even save the link in the bookmarks.– Roberto de Campos
@Robertodecampos Neither do I! If you do tests, then tell me?
– rbz
I’ll let you know in chat.
– Roberto de Campos