Helio13 Posted July 30, 2012 at 02:35 PM Report Share #470981 Posted July 30, 2012 at 02:35 PM Boa tarde! Estou com uma duvida para utilizar o timestmap do mysql Eu quero transferir dados de uma tabela A para uma tabela B, mas queria que na tabela B houve um campo do tipo timstamp que me guarda se a data e hora em que o registo tinha sido transferido da tabela A para a B... Como posso fazer isso? Alguém me pode ajudar? Obrigado Cumprimentos Link to comment Share on other sites More sharing options...
KTachyon Posted July 30, 2012 at 02:52 PM Report Share #470987 Posted July 30, 2012 at 02:52 PM INSERT INTO tabela2 (col1, col2, col3, time) SELECT col1, col2, col3, NOW() as time FROM tabela1 “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Helio13 Posted July 30, 2012 at 03:01 PM Author Report Share #470989 Posted July 30, 2012 at 03:01 PM Entendi isso, mas... A partir deste codigo que tenho INSERT INTO sip2.temporaria2 (select * from sip2.temporaria where sip2.temporaria.CODIGO_INVENTARIO not in ( select CODIGO_INVENTARIO from sip2.definitiva where sip2.temporaria.CODIGO_INVENTARIO = sip2.definitiva.CODIGO_INVENTARIO)); Que insere na tabela temporaria2 os registos que estao na tabela temporaria que não estão na tabela temporaria2...como meto aqui o timestamp? Link to comment Share on other sites More sharing options...
KTachyon Posted July 30, 2012 at 03:45 PM Report Share #470999 Posted July 30, 2012 at 03:45 PM Pah, é mesmo só verificar se o CODIGO_INVENTARIO que estás a ir buscar à tabela temporaria não está já na temporaria2. Adicionas a coluna extra que pretendes adicionar à lista. INSERT INTO temp2 SELECT *, NOW() AS time_stamp FROM temp WHERE CODIGO_INVENTARIO NOT IN (SELECT CODIGO_INVENTARIO FROM temp2) “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Helio13 Posted July 30, 2012 at 04:56 PM Author Report Share #471019 Posted July 30, 2012 at 04:56 PM Ok, obrigado pela ajuda. Já consegui... Cumprimentos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now