2
Hey, guys, I have a question. I need to copy the data from an integer column to another decimal column of the same table, that in Mysql. Is it possible to do ? there may be some inconsistencies in the data? And how can I do?
2
Hey, guys, I have a question. I need to copy the data from an integer column to another decimal column of the same table, that in Mysql. Is it possible to do ? there may be some inconsistencies in the data? And how can I do?
3
I’m not sure I understand what you want to do, but it seems to me something very simple. Try to do the following, see if it helps you:
update tabela
set coluna_decimal = coluna_inteira
2
Just change the type, it will solve the problem:
ALTER TABLE `nome_da_tabela`
CHANGE `nome_da_coluna_inteiro` `nome_da_coluna_decimal` DECIMAL (6,2);
And to copy the data, you can make a select Insert:
SET SQL_SAFE_UPDATES = 0;
INSERT INTO tabela_destino
(campo1, campo2, campo3)
SELECT campo1, campo2, campo3 FROM tabela_origem;
Browser other questions tagged mysql sql database
You are not signed in. Login or sign up in order to post.
In fact you don’t even need to copy, in these cases you can simply edit the table by changing the type. BUT, I always think it is good to copy and delete the previous one when it is to change type, to avoid labor repairing disasters ;)
– Bacco
Thanks guys. They helped me out. I think I’ll try to first change the field to decimal on a test basis and then go to the real bank.
– A. Gontijo
You can answer your own question if you have found a different solution to the answers.
– user28595
yes it is possible, if it were otherwise could have problems.
– Ruberlei Cardoso