mysql匯出資料意義 11 mysql匯出資料

2021-10-19 19:27:35 字數 1247 閱讀 3020

1、使用select... into outfile語句匯出資料

(1)txt格式

select *from runoob.tb1 into outfile '/tmp/runoob.txt';

(2)csv格式

select * from passwd into outfile '/tmp/runoob.txt' fields terminated by ',' enclosed by '"' lines terminated by '\r\n';

(3)生成一種檔案,各值用逗號隔開,這種格式可以被許多程式使用

select a,b,a+b into outfile '/tmp/runoob.txt' fields terminated by ',' enclosed by '"' lines terminated by '\n' form test_table;

2、匯出表作為原始資料

mysqldump是mysql用於轉儲資料庫的實用程式,它主要產生乙個sql指令碼,其中包括從頭重新建立資料庫所必須的命令create table insert等。

使用mysqldump匯出資料需要使用--tab選項來指定匯出檔案指定的目錄,該目錄必須是可寫的。

mysqldump -u root -p --no-create-info \ --tab=/rmp runoob runoob_tb1;

3、匯出sql格式的資料

匯出單張表

mysqldump -u root -p runnoob runoob_tb1 > dump.txt

備份整個資料庫

mysqldump -u root -p runoob >database_dump.txt

備份所有資料庫

mysqldump -u root -p --all-databases > database_dump.txt

4、將資料表及資料庫拷貝至其他主機

將資料拷貝到其他的mysql伺服器上:

mysqldump -u root -p database_name table_name > dump.txt

如果備份完整資料庫,則無需使用特定的表名稱

將備份的資料匯入到mysql伺服器中:

mysql -u root -p database_name < dump.txt

直接從伺服器匯入到另一伺服器:

mysqldump -u root -p database_name \ | mysql -h other-host.com database_name;

11 mysql匯出資料

1 txt格式 select from runoob.tb1 into outfile tmp runoob.txt 2 csv格式 select from passwd into outfile tmp runoob.txt fields terminated by enclosed by lin...

Datax從Hive中匯出資料寫入到MySQL

hive1.2.x 版本支援的資料型別已經很豐富了,但是datax目前還支援不了這麼多的資料型別,如果不注意的話,將會丟擲很多奇怪的問題 比如 髒資料 的問題。datax 內部型別 hive表 資料型別 long tinyint,smallint,int,bigint double float,do...

mysql 匯出資料

方法一 select.into outfile mysql select from mytbl into outfile tmp mytbl.txt 檢視mytbl.txt中內容如下 mysql system cat tmp mytbl.txt1 name1 2 name2 3 n 匯出的檔案中資料...