从品牌网站建设到网络营销策划,从策略到执行的一站式服务
1、select into outfile可以导出数据到指定目录下的文件中
成都创新互联公司主要从事成都网站建设、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务鹿泉,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108语法:
SELECT ... INTO OUTFILE 'file_name' [CHARACTER SET charset_name] [export_options] export_options: [{FIELDS | COLUMNS} [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char'] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string']
2、示例如下:
1)查看要导出数据的表t1
mysql> select * from t1; +------+--------+ | id | name | +------+--------+ | 1 | wang | | 2 | steven | | 3 | tiger | | 4 | lilu | +------+--------+ 4 rows in set (0.00 sec)
2)查看导出的文件
[mysql@oneproxy outfile]$ more t1.file 1,"wang" 2,"steven" 3,"tiger" 4,"lilu"
3)创建要导入的表t2;
mysql> create table t2 as select * from t1 where 1=2; Query OK, 0 rows affected (0.03 sec)
4)将导出的数据导入t2
mysql> LOAD DATA INFILE '/mysql/outfile/t1.file' INTO TABLE t2 FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; Query OK, 4 rows affected (0.01 sec) Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
5)查看导入的数据
mysql> select * from t2; +------+--------+ | id | name | +------+--------+ | 1 | wang | | 2 | steven | | 3 | tiger | | 4 | lilu | +------+--------+ 4 rows in set (0.00 sec)
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图