分类: Mysql/postgreSQL
2009-07-11 14:26:51
设定字段间的分隔符 如逗号 FIELDS TERMINATED BY ','
设定字段包裹的字符,如双引号 OPTIONALLY ENCLOSED BY '"'
设定行分隔符 如换行符\r\n LINES TERMINATED BY '\r\n'
使用select into outfile "filename"语句,前提必须拥有文件的权限。
现在比如:
数据库是mysql
mysql> select * from user into outfile "a.txt";
上面就可以完成将表user从数据库中卸到a.txt文件中。注意文件名要加单引号。那么a.txt文件就在mysql目录下有一个 data目录,它即是数据库文件所放的地方。
例如:select * from books into outfile 'book.txt' fields terminated by ',' optionally enclosed by '''' lines terminated by '\n';