cockroach userfile delete command deletes the files stored in the user-scoped file storage which match the provided pattern, using a SQL connection. If the pattern
'*' is passed, all files in the specified (or default, if unspecified) user-scoped file storage will be deleted. Deletions are not atomic, and all deletions prior to the first failure will occur.
The user must have the
CREATE privilege on the target database. CockroachDB will proactively grant the user
DELETE on the metadata and file tables.
A user can only delete files from their own user-scoped storage, which is accessed through the userfile URI used during the upload. CockroachDB will revoke all access from every other user in the cluster except users in the
admin role. Users in the
admin role can delete from any user's storage.
Delete a file:
$ cockroach userfile delete <file | dir> [flags]
$ cockroach userfile delete --help
||A comma-separated list of
||The path to the certificate directory containing the CA and client certificates and client key.
||Reveal the SQL statements sent implicitly by the command-line utility.|
||A connection URL to use instead of the other arguments.
Default: no URL
||The SQL user that will own the client session.
Delete all files in the default storage
To delete all files in the directory, pass the
$ cockroach userfile delete '*' --certs-dir=certs
deleted userfile://defaultdb.public.userfiles_root/test-data-2.csv deleted userfile://defaultdb.public.userfiles_root/test-data.csv deleted userfile://defaultdb.public.userfiles_root/test-upload/test-data.csv
Note that because a fully qualified userfile URI was not specified, files in the default user-scoped storage (
userfile://defaultdb.public.userfiles_$user/) were deleted.
Delete a specific file
To delete a specific file, include the file destination in the command:
$ cockroach userfile delete test-data.csv --certs-dir=certs
Delete files that match the provided pattern
To delete all files that match a pattern, use
$ cockroach userfile delete '*.csv' --certs-dir=certs
deleted userfile://defaultdb.public.userfiles_root/test-data-2.csv deleted userfile://defaultdb.public.userfiles_root/test-data.csv
Delete files from a non-default userfile URI
If you uploaded a file to a non-default userfile URI (e.g.,
cockroach userfile upload /Users/maxroach/Desktop/test-data.csv userfile://testdb.public.uploads/test-data.csv
Use the same URI to delete it:
cockroach userfile delete userfile://testdb.public.uploads
cockroach userfile upload
cockroach userfile list
cockroach userfile get