Python 使用Django删除postgresql数据库中的所有表,而不删除数据库
我正在运行AWS Elastic Beans,它会自动为我设置一个工作的postgresql数据库实例和连接。因此,我不想只删除数据库实例并自己配置它。我宁愿从python/django中删除数据库中的所有表。我也不想删除所有表的内容(python manage.py flush的功能) 我希望数据库返回到可以运行Python 使用Django删除postgresql数据库中的所有表,而不删除数据库,python,django,postgresql,amazon-web-services,cloud,Python,Django,Postgresql,Amazon Web Services,Cloud,我正在运行AWS Elastic Beans,它会自动为我设置一个工作的postgresql数据库实例和连接。因此,我不想只删除数据库实例并自己配置它。我宁愿从python/django中删除数据库中的所有表。我也不想删除所有表的内容(python manage.py flush的功能) 我希望数据库返回到可以运行python manage.py migrate的状态,它将根据当前模型定义创建所有空表 谢谢我不想删除表中的所有数据,我想删除表本身,这样我就可以在以后运行一个新的python ma
python manage.py migrate
的状态,它将根据当前模型定义创建所有空表
谢谢我不想删除表中的所有数据,我想删除表本身,这样我就可以在以后运行一个新的python manage.py migrate,以使用我的新(可能已更改)模型获得干净的表。python manage.py migrate appname zero-命令将删除您的table@IainShelvington是的,的确如此,谢谢
# Prints the SQL statements that would be executed for the flush command. Will delete all the data from tables in database
django-admin sqlflush
# You can pass the name of your database specifically. Defaults to default.
--database DATABASE
# If you want to delete all the tables of your app, then you can run the command
python manage.py migrate appname zero