Use Userfile for Bulk Operations

On this page Carat arrow pointing down
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

icon/buttons/copy
$ 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

icon/buttons/copy
$ 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

icon/buttons/copy
$ 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

icon/buttons/copy
> 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.

See also


Yes No
On this page

Yes No