Answers:
如果通过composer安装模块,则可以创建Setup/Uninstall.php将在运行时执行的文件bin/magento module:uninstall -r [Namespace]_[Module]。
该Uninstall.php文件应如下所示:
<?php
namespace Namespace\Module\Setup;
class Uninstall implements \Magento\Framework\Setup\UninstallInterface
{
    public function uninstall(
        \Magento\Framework\Setup\SchemaSetupInterface $setup,
        \Magento\Framework\Setup\ModuleContextInterface $context
    ) {
        if ($setup->tableExists('table_name_here')) {
            $setup->getConnection()->dropTable('table_name_here');
        }
    }
}如果手动安装模块,则需要手动清理数据库,还需要删除模块添加的表。
installer script。