“MySQL导入导出CSV格式”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
第25行: 第25行:
  
 
</pre>
 
</pre>
 +
=R=
 +
[https://www.cnblogs.com/jluzhsai/p/4980210.html  Bash中使用MySQL导入导出CSV格式数据[转<nowiki>]</nowiki> ]
 +
 +
[[category:mysql]] [[category:dba]]

2021年10月29日 (五) 08:04的最新版本

table

针对 单个table  menu
MariaDB [mycmdb]> SELECT * INTO OUTFILE "/tmp/out.csv" FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'   FROM menu;
Query OK, 31 rows affected (0.014 sec)

-- 这里写你的sql 语句
select * from myUser 
into outfile '/tmp/test.csv' 
fields terminated by ',' optionally enclosed by '"' escaped by '"' 
lines terminated by '\r\n'; 


#一个例子
use  system;
select id,old_id,old_supplier_id,product_type,name,sales_platform,corporate_entity,insurancid from product where add_time < 16350 and supplier_id = 0 and old_id > 0 and deleted_at is null
into outfile '/tmp/test.csv' 
fields terminated by ',' optionally enclosed by '"' escaped by '"' 
lines terminated by '\r\n'; 






R

Bash中使用MySQL导入导出CSV格式数据[转]