Create db_schema_whitelist.json file using CLI in Magento 2.

In Magento 2, Magento Version 2.3 and higher version contains the declarative schema approach for database tables history.

You can create db_schema_whitelist.json using the command line with a single command,

The generated file location is the <Vendorname>/<Modulename>/etc/db_schema_whitelist.json in your module.

This file provides a history of modules all tables, columns, and keys added with a declarative schema.

You need to run the below command to generate a file,

php bin/magento setup:db-declaration:generate-whitelist [options]

Where [options] will be,
--module-name[=Modulename] specifies the Module name to generate a whitelist.

If the Module name is not specified, then the default behavior is to generate a whitelist for all the modules in a system. You can set options  --module-name=all for all the modules.

If your module name is Vendor_Packagename and you want to generate a db_schema_whitelist.json file, Run the command,

php bin/magento setup:db-declaration:generate-whitelist --module-name=Vendor_Packagename

You can see your db_schema_whitelist.json file in your modules etc folder.