SAVE_FILE()
Function Description
The SAVE_FILE() function is used to write content to the datalink pointer file, referring to the line to return the written content byte length.
Function Syntax
>SAVE_FILE(datalink_type_data,content) ;
Parameter definition
| Parameters | Description |
|---|---|
| datalink_type_data | datalink type data, you can use the cast() function to convert |
| content | Need to write the contents of the datalink pointing to the file |
Example
drop stage if exists tab1;
create stage stage01 url='file:///Users/admin/case/';
mysql> select save_file(cast('stage://stage01/test.csv' as datalink), 'this is a test message');
+------------------------------------------------------------------------------------------------------------------------------
| save_file(cast(stage://stage01/test.csv as datalink), this is a test message) |
+------------------------------------------------------------------------------------------------------------------------------
| 22 |
+------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.00 sec)
mysql> select save_file(cast('file:///Users/admin/case/test1.csv' as datalink), 'this is another test message');
+------------------------------------------------------------------------------------------------------------------------------
| save_file(cast(file:///Users/admin/case/test1.csv as datalink), this is another test message) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 28 |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.01 sec)
(base) admin@192 case % cat test.csv
This is a test message
(base) admin@192 case % cat test1.csv
This is another test message