Version 11.3.1
Loading...
Searching...
No Matches
WiredTiger command line utility

WiredTiger includes a command line utility, wt.

SYNOPSIS

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] command [command-specific arguments]

DESCRIPTION

The wt tool is a command-line utility that provides access to various pieces of the WiredTiger functionality.

OPTIONS

There are several global options:

-B
Maintain release 3.3 log file compatibility.
-C config
Specify configuration strings for the wiredtiger_open function.
-E secretkey
Specify an encryption secret key for the wiredtiger_open function.
-h directory
Specify a database home directory.
-L
Forcibly turn off logging subsystem for debugging purposes.
-m
Verify the WiredTiger metadata as part of opening the database.
-R
Run recovery if the underlying database is configured to do so.
-r
Access the database via a readonly connection
-S
Run salvage recovery if the underlying database is configured to do so.
-V
Display WiredTiger version and exit.
-v
Set verbose output.
-?
Print the help message and exit.

Unless otherwise described by a wt command, the wt tool exits zero on success and non-zero on error.

The wt tool supports several commands. You can use the -? option with any of these commands to print the help message. If configured in the underlying database, some commands will run recovery when opening the database. If the user wants to force recovery on any command, use the -R option. In general, commands that modify the database or tables will run recovery by default and commands that only read data will not run recovery. It is recommended when attempting to diagnose a corrupt database, that the -r flag be used. This flag will open the connection read-only and prevent utility commands from writing prevent utility commands from writing to any of the existing database objects.


wt alter

Alter a table.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] alter uri configuration ...

The uri and configuration pairs may be specified to the alter command. These configuration pairs can be used to modify the configuration values from those passed to the WT_SESSION::create call.

The uri part of the configuration pair should match only one of the objects being altered, but may be a prefix of the object being matched. For example, the following two sets of configuration pairs are equivalent in the case of altering a single table named xxx.

table access_pattern_hint=sequential
table:xxx access_pattern_hint=sequential

It's an error, however, to specify a matching prefix that matches more than a single object being altered.

Multiple configuration arguments may be specified. For example, the following two sets of configuration pairs are equivalent:

table:xxx access_pattern_hint=random,cache_resident=false
table:xxx access_pattern_hint=random table:xxx cache_resident=false

wt backup

Perform a backup of a database or set of data sources.

The backup command performs a backup of the database, copying the underlying files to a specified directory, which can be subsequently opened as a WiredTiger database. See Backups for more information, and File permissions for specifics on the copied file permissions.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] backup [-t uri] directory

Options

The following are command-specific options for the backup command:

-t uri
By default, the backup command does a backup of the entire database; the -t option changes the backup command to do a backup of only the named data sources.

wt compact

Compact a table.

The compact command attempts to rewrite the specified table to consume less disk space.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] compact [-c config] uri

Options

The following are command-specific options for the compact command:

-c
Include a configuration string to be passed to WT_SESSION::compact.

wt copyright

Print the copyright information.

The copyright command just prints the copyright information and exits.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] copyright

Options

The copyright command has no command-specific options.


wt create

Create a table.

The create command creates the specified uri with the specified configuration. It is equivalent to a call to WT_SESSION::create with the specified string arguments.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] create [-c config] uri

Options

The following are command-specific options for the create command:

-c
Include a configuration string to be passed to WT_SESSION::create.

wt downgrade

Downgrade a database.

The downgrade command downgrades the database to the specified compatibility version.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] downgrade -V version

Options

The following are command-specific options for the downgrade command:

-V version
The -V option is required, and specifies the version to which the database is downgraded.

wt drop

Drop a table.

The drop command drops the specified uri. It is equivalent to a call to WT_SESSION::drop with the "force" configuration argument.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] drop uri

Options

The drop command has no command-specific options.


wt dump

Export data in a text format.

The dump command outputs the specified table in a portable format which can be re-loaded into a new table using the load command.

See Dump Formats for details of the dump file formats.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] dump [-ejnprx] [-c checkpoint] [-f output] [-k key] [-l lower bound] [-t timestamp] [-u upper bound] [-w window] uri

Options

The following are command-specific options for the dump command:

-c
By default, the dump command opens the most recent version of the data source; the -c option changes the dump command to dump as of the named checkpoint.
-e
Start the explore mode to dump the file interactively.
-f
By default, the dump command output is written to the standard output; the -f option re-directs the output to the specified file.
-j
Dump in JSON (JavaScript Object Notation) format.
-k
The specific key to look for in the format of the data packed into key items.
-l
The lower bound of the key range to dump.
-n
If the requested key (see the -k option) cannot be found, return the key retrieved by search_near.
-p
Dump in human-readable format (pretty-print). The -p flag is incompatible with the load command. The -p flag can be combined with -x. In this case, raw data elements will be formatted like -x with hexadecimal encoding.
-r
Dump in reverse order, from largest key to smallest.
-t
By default, the dump command opens the most recent version of the data source; the -t option changes the dump command to dump as of the specified timestamp.
-u
The upper bound of the key range to dump.
-w
Dump n records before and after the record sought.
-x
Dump all characters in a hexadecimal encoding (the default is to leave printable characters unencoded). The -x flag can be combined with -p. In this case, the dump will be formatted similar to -p except for raw data elements, which will look like -x with hexadecimal encoding. If the two options are combined the output is no longer compatible with load.

wt list

List the tables in the database.

By default, the list command prints out the tables stored in the database. If a URI is specified as an argument, only information about that data source is printed.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] list [-cv] [uri]

Options

The following are command-specific options for the list command:

-c
If the -c option is specified, the data source's checkpoints are printed in a human-readable format.
-v
If the -v option is specified, the data source's complete schema table value is printed.

wt load

Load a table from dump output.

The load command reads the standard input for data and loads it into a table, creating the table if it does not yet exist. The data should be the format produced by the dump command; see Dump Formats for details.

By default, if the table already exists, key/value pairs in the table will be overwritten by new data with matching keys (use the -n option to make an attempt to overwrite existing data return an error). Existing keys will not be removed.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] load [-ajn] [-f input] [-r name] [uri configuration ...]

Options

The following are command-specific options for the load command:

-a
If the -a option is specified, record number keys in the input are ignored and the data is appended to the data source and assigned new record number keys. The -a option is only applicable when loading into a column store.
-f
By default, the load command reads from the standard input; the -f option reads the input from the specified file.
-j
Load input in the JSON (JavaScript Object Notation) format that was created by the dump -j command.
-n
By default, input data will overwrite existing data where the key/value pair already exists in the data source; the -n option causes the load command to fail if there's an attempt to overwrite already existing data.
-r
By default, the load command uses the table name taken from the input; the -r option renames the data source.

Additionally, uri and configuration pairs may be specified to the load command. These configuration pairs can be used to modify the configuration values from the dump header passed to the WT_SESSION::create call.

The uri part of the configuration pair should match only one of the objects being loaded, but may be a prefix of the object being matched. For example, the following two sets of configuration pairs are equivalent in the case of loading a single table named xxx.

table block_allocation=first
table:xxx block_allocation=first

It's an error, however, to specify a matching prefix that matches more than a single object being loaded.

Multiple configuration arguments may be specified. For example, the following two sets of configuration pairs are equivalent:

table:xxx block_allocation=first,prefix_compress=false
table:xxx block_allocation=first table:xxx prefix_compress=false

wt loadtext

Load text into a table.

The loadtext command reads the standard input for text and loads it into a table. The input data should be printable characters, with newline delimiters for each key or value.

The loadtext command does not create the object if it does not yet exist.

In the case of inserting values into a column-store table, each value is appended to the table; in the case of inserting values into a row-store table, lines are handled in pairs, where the first line is the key and the second line is the value. If the row-store table already exists, key/value pairs in the table will be overwritten by new data with matching keys. For either column-store or row-store tables, existing keys will not be removed.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] loadtext [-f input] uri

Options

The following are command-specific options for the loadtext command:

-f
By default, the loadtext command reads from the standard input; the -f option reads the input from the specified file.

wt printlog

Display the database log. By default any operations in the log containing user data are redacted.

The printlog command outputs the database log.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] printlog [-mux] [-f output] [-l start-file,start-offset]|[-l start-file,start-offset,end-file,end-offset]

Options

The following are command-specific options for the printlog command:

-f
By default, the printlog command output is written to the standard output; the -f option re-directs the output to the specified file.
-l
Specify the start LSN from which the log will be printed, and optionally also the end LSN.
-m
Print only message-type log records.
-u
Display user data.
-x
Keys and value items in the log are printed in hex format in addition to the default string format.

wt read

Read records from a table.

The read command prints out the records associated with the specified keys from the specified data source. The data source must be configured with string or record number keys and string values.

The read command exits non-zero if a specified record is not found.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] read uri key ...

Options

The read command has no command-specific options.


wt rename

Rename a table.

The rename command renames the specified table.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] rename uri new-uri

Options

The rename command has no command-specific options.


wt salvage

Recover data from a corrupted table.

The salvage command salvages the specified data source, discarding any data that cannot be recovered. Underlying files are re-written in place, overwriting the original file contents.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] salvage [-F] uri

Options

The following are command-specific options for the salvage command:

-F
By default, salvage will refuse to salvage tables that fail basic tests (for example, tables that don't appear to be in a WiredTiger format). The -F option forces the salvage of the table, regardless.

wt stat

Display database or data source statistics.

The stat command outputs run-time statistics for the WiredTiger engine, or, if specified, for the URI on the command-line.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] stat [-f] [uri]

Options

The following are command-specific options for the stat command:

-f
Include only "fast" statistics in the output (equivalent to passing statistics=(fast)) to WT_SESSION::open_cursor.

wt truncate

Truncate a table, removing all data.

The truncate command truncates the specified uri. It is equivalent to a call to WT_SESSION::truncate with no start or stop specified.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] truncate uri

Options

The truncate command has no command-specific options.


wt verify

Check the structural integrity of a table.

The verify command verifies the specified table if a URI argument is provided, exiting success if the data source is correct, and failure if the data source is corrupted. If no URI argument is provided, it verifies each table in the database, reporting on any that are damaged. If the abort on error option -a is specified, terminate the verification process if one of the tables is damaged. Currently, the verify operation is not supported with tiered tables and the history store file.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] verify [-acSstu] [-d dump_address | dump_blocks | dump_layout | dump_offsets=#,# | dump_pages ] [uri]

Options

The following are command-specific options for the verify command:

-a Abort immediately if verify encounters a damaged table instead of continuing to verify the rest of the tables in the database.

-c Continue to the next page after encountering error during verification.

-d [config] This option allows you to specify values which you want to be displayed when verification is run. See the WT_SESSION::verify configuration options.

-k Display only the key data when dumping with configuration dump_blocks or dump_page.

-S This option enables strict mode and treats any verification problem as an error.

-s This option allows you to verify against the stable timestamp, valid only after a rollback-to-stable operation. See the WT_SESSION::verify configuration options.

-t Do not clear transaction IDs during verification.

-u Display the application data when dumping with configuration dump_blocks or dump_page.


wt write

Write records to a table.

The write command stores records into the specified data source. The data source must be configured with string or record number keys and string values.

If the write command is called with the -a option, each command-line argument is a single value to be appended to the specified column-store data source. If the write command is called with the -r option, the command-line argument is a key. If the write command is called with neither the -a nor the -r option, the command-line arguments are key/value pairs.

Attempting to overwrite an already existing record will fail.

Synopsis

wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] write -a uri value ...
wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] write -r uri key
wt [-BLmRrSVv] [-C config] [-E secretkey ] [-h directory] write [-o] uri key value ...

Options

The following are command-specific options for the write command:

-a
Append each value as a new record in the column-store data source.
-r
Remove an existing record from the data source.
-o
By default, attempting to overwrite an already existing record will fail. The -o option changes write to overwrite previously existing records.