如果我们从一个包含NULL值的表中导出数据,那么MySQL将在CSV文件中为具有NULL值的记录存储\N。可以通过以下示例说明:
假设我们想要导出表格'student_info'的值,该表格具有以下数据:
mysql> Select * from Student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla | Computers | | 130 | Ram | Jhansi | Computers | | 132 | Shyam | Chandigarh | Economics | | 133 | Mohan | Delhi | Computers | | 150 | Saurabh | NULL | Literature | +------+---------+------------+------------+ 7 rows in set (0.00 sec)
我们可以看到结果中 id 为 150 的地址字段有一个 NULL 值。现在以下查询将将此表的数据导出到 Student_27.CSV -
mysql> Select * from Student_info INTO OUTFILE 'C:/mysql/bin/mysql-files/student_27.csv' FIELDS TERMINATED BY ','; Query OK, 7 rows affected (0.02 sec)
上述查询已将以下值存储在文件Student_27.CSV中 −
101 YashPal Amritsar History 105 Gaurav Chandigarh Literature 125 Raman Shimla Computers 130 Ram Jhansi Computers 132 Shyam Chandigarh Economics 133 Mohan Delhi Computers 150 Saurabh \N Literature
我们可以看到 MySQL 在表有 NULL 值的地方存储 \N。
以上就是如果我们从包含 NULL 值的表中将数据导出到 CSV 文件,MySQL 如何评估?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号