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

来自linux中国网wiki
跳到导航 跳到搜索
(创建页面,内容为“=table= <pre> 针对 单个table menu MariaDB [mycmdb]> SELECT * INTO OUTFILE "/tmp/out.csv" FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' FRO…”)
 
第5行: 第5行:
 
Query OK, 31 rows affected (0.014 sec)
 
Query OK, 31 rows affected (0.014 sec)
  
 +
-- 这里写你的sql 语句
 
select * from myUser  
 
select * from myUser  
 
into outfile '/tmp/test.csv'  
 
into outfile '/tmp/test.csv'  
 
fields terminated by ',' optionally enclosed by '"' escaped by '"'  
 
fields terminated by ',' optionally enclosed by '"' escaped by '"'  
 
lines terminated by '\r\n';  
 
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';
 +
 +
 +
 +
 +
  
 
</pre>
 
</pre>

2021年10月29日 (五) 08:02的版本

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';