Blogger Information
Blog 33
fans 0
comment 1
visits 43144
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
MySQL高级编程
萝卜温的博客
Original
914 people have browsed it
  • 将数据表导入或者导出为普通文件

mysql> select * from student into outfile 'D:/student.txt' fields terminated by ',' enclosed by ''; //导出表为文件
mysql> load data infile 'd:\code.txt' into table code charset utf8 fields terminated by ',' enclosed by ''; //导入文件为表

注意:上面可能会出现 “1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement”这类型的错误,主要是MySQL指定了导入和导出文件的安全目录的原因,通过将文件导入/出放到安全目录或者在my.ini中更改安全目录即可!可以参考这篇文章:

MYSQL新特性secure_file_priv对读写文件的影响

  • 事务(InnoDB支持事务,MyISAM不支持事务)

mysql> set autocommit=0;  //关闭自动提交,自动提交会导致语句立即生效!如果要开启自动提交,需要用 start transaction 开启一个事务!
mysql> commit;  //或者rollback

注意:事务符合ACID要求,详细可以参考这篇文章

什么是数据库ACID?

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post