{"meta":{"title":"database finalize","intro":"[Plumbing] Final steps in database creation.","product":"Security and code quality","breadcrumbs":[{"href":"/en/code-security","title":"Security and code quality"},{"href":"/en/code-security/reference","title":"Reference"},{"href":"/en/code-security/reference/code-scanning","title":"Code scanning"},{"href":"/en/code-security/reference/code-scanning/codeql","title":"CodeQL"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual","title":"CodeQL CLI manual"},{"href":"/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-finalize","title":"database finalize"}],"documentType":"article"},"body":"# database finalize\n\n\\[Plumbing] Final steps in database creation.\n\n> \\[!NOTE]\n> This content describes the most recent release of the CodeQL CLI. For more information about this release, see <https://github.com/github/codeql-cli-binaries/releases>.\n>\n> To see details of the options available for this command in an earlier release, run the command with the <span style=\"white-space: nowrap;\">`--help`</span> option in your terminal.\n\n## Synopsis\n\n```shell copy\ncodeql database finalize [--dbscheme=<file>] [--threads=<num>] [--ram=<MB>] <options>... -- <database>\n```\n\n## Description\n\n\\[Plumbing] Final steps in database creation.\n\nFinalize a database that was created with [codeql database init](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-init) and subsequently seeded with analysis data using [codeql database trace-command](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-trace-command). This needs to happen before the new database can be queried.\n\n## Options\n\n### Primary Options\n\n#### `<database>`\n\n\\[Mandatory] Path to the CodeQL database under construction. This must\nhave been prepared for extraction with [codeql database init](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-init).\n\nIf the `--db-cluster` option is given, this is not a database itself,\nbut a directory that *contains* databases, and all of those databases\nwill be processed together.\n\n#### `--[no-]db-cluster`\n\nIndicates that the directory given on the command line is not a database\nitself, but a directory that *contains* one or more databases under\nconstruction. Those databases will be processed together.\n\n#### `--additional-dbs=<database>[:<database>...]`\n\n\\[Advanced] Path to additional CodeQL databases under construction.\nThese will not themselves be finalized, but the data from them will be\nincluded in the finalized database being created. This is an advanced\noption that may not have the desired effect in all cases. For more\ninformation, please refer to the documentation of [codeql database import](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/database-import).\n\nIf the `--db-cluster` option is given, it is expected that these will be\ndatabase clusters rather than individual CodeQL databases.\n\n(Note: On Windows the path separator is `;`).\n\n#### `--no-cleanup`\n\n\\[Advanced] Suppress all database cleanup after finalization. Useful\nfor debugging purposes.\n\n#### `--no-pre-finalize`\n\n\\[Advanced] Skip any pre-finalize script specified by the active CodeQL\nextractor.\n\n#### `--[no-]skip-empty`\n\n\\[Advanced] Output a warning instead of failing if a database is empty\nbecause no source code was seen during the build. The empty database\nwill be left unfinalized.\n\n### Options for controlling the TRAP import operation\n\n#### `-S, --dbscheme=<file>`\n\n\\[Advanced] Override the auto-detected dbscheme definition that the\nTRAP files are assumed to adhere to. Normally, this is taken from the\ndatabase's extractor.\n\n#### `-j, --threads=<num>`\n\nUse this many threads for the import operation.\n\nDefaults to 1. You can pass 0 to use one thread per core on the machine,\nor -*N* to leave *N* cores unused (except still use at least one\nthread).\n\n#### `-M, --ram=<MB>`\n\nUse this much memory for the import operation.\n\n### Low-level dataset cleanup options\n\n#### `--max-disk-cache=<MB>`\n\nSet the maximum amount of space that the disk cache for intermediate\nquery results can use.\n\nIf this size is not configured explicitly, the evaluator will try to use\na \"reasonable\" amount of cache space, based on the size of the dataset\nand the complexity of the queries. Explicitly setting a higher limit\nthan this default usage will enable additional caching which can speed\nup later queries.\n\n#### `--min-disk-free=<MB>`\n\n\\[Advanced] Set target amount of free space on file system.\n\nIf `--max-disk-cache` is not given, the evaluator will try hard to\ncurtail disk cache usage if the free space on the file system drops\nbelow this value.\n\n#### `--min-disk-free-pct=<pct>`\n\n\\[Advanced] Set target fraction of free space on file system.\n\nIf `--max-disk-cache` is not given, the evaluator will try hard to\ncurtail disk cache usage if the free space on the file system drops\nbelow this percentage.\n\n#### `--cache-cleanup=<mode>`\n\nSelect how aggressively to trim the cache. Choices include:\n\n`clear`: Remove the entire cache, trimming down to the state of a\nfreshly extracted dataset\n\n`trim` *(default)*: Trim everything except explicitly \"cached\"\npredicates.\n\n`fit`: Simply make sure the defined size limits for the disk cache are\nobserved, deleting as many intermediates as necessary.\n\n`overlay`: Trim to just the data that will be useful when evaluating\nagainst an overlay.\n\n#### `--cleanup-upgrade-backups`\n\nDelete any backup directories resulting from database upgrades.\n\n### Options for checking imported TRAP\n\n#### `--[no-]check-undefined-labels`\n\n\\[Advanced] Report errors for undefined labels.\n\n#### `--[no-]check-unused-labels`\n\n\\[Advanced] Report errors for unused labels.\n\n#### `--[no-]check-repeated-labels`\n\n\\[Advanced] Report errors for repeated labels.\n\n#### `--[no-]check-redefined-labels`\n\n\\[Advanced] Report errors for redefined labels.\n\n#### `--[no-]check-use-before-definition`\n\n\\[Advanced] Report errors for labels used before they're defined.\n\n#### `--[no-]fail-on-trap-errors`\n\n\\[Advanced] Exit non-zero if an error occurs during trap import.\n\n#### `--[no-]include-location-in-star`\n\n\\[Advanced] Construct entity IDs that encode the location in the TRAP\nfile they came from. Can be useful for debugging of TRAP generators, but\ntakes up a lot of space in the dataset.\n\n#### `--[no-]linkage-aware-import`\n\n\\[Advanced] Controls whether [codeql dataset import](/en/code-security/reference/code-scanning/codeql/codeql-cli-manual/dataset-import) is linkage-aware *(default)* or not. On projects where this part of database creation\nconsumes too much memory, disabling this option may help them progress\nat the expense of database completeness.\n\nAvailable since `v2.15.3`.\n\n### Common options\n\n#### `-h, --help`\n\nShow this help text.\n\n#### `-J=<opt>`\n\n\\[Advanced] Give option to the JVM running the command.\n\n(Beware that options containing spaces will not be handled correctly.)\n\n#### `-v, --verbose`\n\nIncrementally increase the number of progress messages printed.\n\n#### `-q, --quiet`\n\nIncrementally decrease the number of progress messages printed.\n\n#### `--verbosity=<level>`\n\n\\[Advanced] Explicitly set the verbosity level to one of errors,\nwarnings, progress, progress+, progress++, progress+++. Overrides `-v`\nand `-q`.\n\n#### `--logdir=<dir>`\n\n\\[Advanced] Write detailed logs to one or more files in the given\ndirectory, with generated names that include timestamps and the name of\nthe running subcommand.\n\n(To write a log file with a name you have full control over, instead\ngive `--log-to-stderr` and redirect stderr as desired.)\n\n#### `--common-caches=<dir>`\n\n\\[Advanced] Controls the location of cached data on disk that will\npersist between several runs of the CLI, such as downloaded QL packs and\ncompiled query plans. If not set explicitly, this defaults to a\ndirectory named `.codeql` in the user's home directory; it will be\ncreated if it doesn't already exist.\n\nAvailable since `v2.15.2`."}