当我使用 !spool 命令时,目标文件会附加结果。例子:
$ touch current.spool
$ cat curr_ts.sql
!spool current.spool
select CURRENT_TIMESTAMP;
$ snowsql -f curr_ts.sql <--- 1st execution of the script
* SnowSQL * v1.1.86
Type SQL statements or !help
+-------------------------------+
| CURRENT_TIMESTAMP |
|-------------------------------|
| 2020-04-21 13:35:59.983 -0400 |
+-------------------------------+
1 Row(s) produced. Time Elapsed: 0.096s
Goodbye!
$ cat current.spool
+-------------------------------+
| CURRENT_TIMESTAMP |
|-------------------------------|
| 2020-04-21 13:35:59.983 -0400 |
+-------------------------------+
$ snowsql -f curr_ts.sql <--- 2nd (supposedly independent) execution of the script
* SnowSQL * v1.1.86
Type SQL statements or !help
+-------------------------------+
| CURRENT_TIMESTAMP |
|-------------------------------|
| 2020-04-21 13:36:17.629 -0400 |
+-------------------------------+
1 Row(s) produced. Time Elapsed: 0.098s
Goodbye!
[1019] bjs13b@igloo:/home/bjs13b/snowsql $ cat current.spool
+-------------------------------+
| CURRENT_TIMESTAMP |
|-------------------------------|
| 2020-04-21 13:35:59.983 -0400 |
+-------------------------------+
+-------------------------------+
| CURRENT_TIMESTAMP | <--- file NOT replaced by 2nd execution!
|-------------------------------|
| 2020-04-21 13:36:17.629 -0400 |
+-------------------------------+
[编辑希望能澄清问题]
如果每次执行都应该创建一个每小时文件,那么每次执行都会将数据添加到每小时文件中......对于每小时数据集来说就是如此。
我知道很多解决方法,但这是关于假脱机的具体问题。我更喜欢改变 spool 命令行为的选项。在其他系统中,我习惯了文件被覆盖,这一直在咬我!