export-import
Kategorie: mysql

export do *.sql

mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql


import csv
LOAD DATA LOCAL INFILE "/usr/local/.../Název_souboru.csv" INTO TABLE Název_tabulky FIELDS TERMINATED BY ";";

import *.sql
mysql -u USERNAME -p DATABASE < FILENAME.sql

export do csv
mysql -uexampleuser -pletmein exampledb -B -e "select * from \`person\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv
nebo lepe
SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;


29.3.2007 12:19:44