zppinto Posted August 13, 2012 at 12:38 PM Report Share #472133 Posted August 13, 2012 at 12:38 PM Como posso fazer o update do ficheiro? SELECT * FROM teste.dados INTO OUTFILE 'file.txt'; COLUMNS TERMINATED BY ',' LINES TERMINATED BY '\r\n'; Isto porque da 1ª vez que o ficheiro é criado, o código funciona perfeitamente, mas se o volto a executar diz que o ficheiro já existe e não o reescreve, como eu pretendia... Obrigado. Link to comment Share on other sites More sharing options...
KTachyon Posted August 13, 2012 at 12:46 PM Report Share #472135 Posted August 13, 2012 at 12:46 PM (edited) Em principio não consegues. Tens que escrever para um ficheiro diferente. Na documentação: http://dev.mysql.com/doc/refman/5.0/en/select-into.html The file is created on the server host, so you must have the FILE privilege to use this syntax. file_name cannot be an existing file, which among other things prevents files such as /etc/passwd and database tables from being destroyed. Edited August 13, 2012 at 12:47 PM by KTachyon “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...
zppinto Posted August 13, 2012 at 12:51 PM Author Report Share #472136 Posted August 13, 2012 at 12:51 PM (edited) E existe alguma alternativa para o que pretendo fazer?! É que eu queria escrever para um ficheiro de texto a tabela dados, e actualiza-la por exemplo de 10 em 10 minutos, para não estar constantemente a consultar a base de dados. Edited August 13, 2012 at 12:52 PM by zppinto Link to comment Share on other sites More sharing options...
KTachyon Posted August 13, 2012 at 01:21 PM Report Share #472141 Posted August 13, 2012 at 01:21 PM Eu trataria disso a partir da shell, apagando ou movendo o ficheiro original. “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...
zppinto Posted August 13, 2012 at 01:49 PM Author Report Share #472144 Posted August 13, 2012 at 01:49 PM Pois mas esta query é para executar em código php, e mover o ficheiro, ou criar novos ficheiros, com nomes diferentes está completamente fora de questão... Mais alguma ideia? Link to comment Share on other sites More sharing options...
pmg Posted August 13, 2012 at 02:02 PM Report Share #472147 Posted August 13, 2012 at 02:02 PM ... para não estar constantemente a consultar a base de dados. Porque??? A consulta a base de dados, num servidor correctamente configurado, é mais rapida e gasta menos recursos que abrir, ler, fechar um ficheiro de texto. What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
zppinto Posted August 13, 2012 at 02:19 PM Author Report Share #472155 Posted August 13, 2012 at 02:19 PM Porque me disseram que seria a melhor forma de o fazer, para não estar constantemente a ir ler à base de dados... Link to comment Share on other sites More sharing options...
pmg Posted August 13, 2012 at 02:24 PM Report Share #472157 Posted August 13, 2012 at 02:24 PM Porque me disseram que seria a melhor forma de o fazer, para não estar constantemente a ir ler à base de dados... É melhor ir constantemente à base de dados, bem configurada! (para isso é que ela foi feita). What have you tried? Não respondo a dúvidas por PM A minha bola de cristal está para compor; deve ficar pronta para a semana. Torna os teus tópicos mais atractivos e legíveis usando a tag CODE para colorir o código! Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted August 13, 2012 at 02:41 PM Report Share #472160 Posted August 13, 2012 at 02:41 PM Porque me disseram que seria a melhor forma de o fazer, para não estar constantemente a ir ler à base de dados... é possivel saber quem te disse isso ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
KTachyon Posted August 13, 2012 at 02:45 PM Report Share #472161 Posted August 13, 2012 at 02:45 PM Tendo em conta que as bases de dados existem para estarem constantemente a ser consultadas... 🙂 “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...
zppinto Posted August 13, 2012 at 02:50 PM Author Report Share #472162 Posted August 13, 2012 at 02:50 PM (edited) Disseram-me pessoalmente e alguém que eu pensava que percebia sobre o assunto, mas afinal não será a melhor forma! Obrigado pela ajuda 🙂 Edited August 13, 2012 at 02:50 PM by zppinto 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