On this page
Warning:
CockroachDB v20.2 is no longer supported as of May 10, 2022. For more details, refer to the Release Support Policy.
New in v20.2: To put files on your CockroachDB cluster without external servers, use userfile
, a per-user bulk file storage. To interact with userfile
, use the following commands:
Once a userfile is uploaded, you can run IMPORT
.
Upload a file
$ cockroach userfile upload /Users/maxroach/Desktop/test-data.csv /test-data.csv --certs-dir=certs
successfully uploaded to userfile://defaultdb.public.userfiles_root/test-data.csv
For more information, see cockroach userfile upload
.
List files
$ cockroach userfile list '*.csv' --certs-dir=certs
userfile://defaultdb.public.userfiles_root/test-data-2.csv
userfile://defaultdb.public.userfiles_root/test-data.csv
For more information, see cockroach userfile list
.
Delete files
$ cockroach userfile delete test-data.csv --certs-dir=certs
deleted userfile://defaultdb.public.userfiles_root/test-data.csv
For more information, see cockroach userfile delete
.
Import from userfile
> IMPORT TABLE customers (
id INT,
dob DATE,
first_name STRING,
last_name STRING,
joined DATE
)
CSV DATA (
'userfile:///test-data.csv'
);
Note:
userfile:///
(note the three slashes) references the default path (userfile://defaultdb.public.userfiles_$user/
).
job_id | status | fraction_completed | rows | index_entries | bytes
---------------------+-----------+--------------------+--------+---------------+-----------
599865027685613569 | succeeded | 1 | 300024 | 0 | 13389972
(1 row)
For more import options, see IMPORT
or IMPORT INTO
.