什么是django命令删除所有表? [英] What is the django command to delete all tables?
问题描述
有没有django命令
Are there django commands that
A。删除所有表格
A. Delete all tables
B。删除所有表中的所有数据
B. delete all data in all tables
C。创建模型中定义的所有表格?
C. Create all tables as defined in the model?
我现在找不到这些!
而且通过命令我的意思是像
And by commands i mean those little things that are like
runserver
等
推荐答案
删除所有表
manage.py sqlclear
将打印sql语句删除所有表
manage.py sqlclear
will print the sql statement to drop all tables
B。删除所有表中的所有数据
B. delete all data in all tables
manage.py flush
将数据库返回到syncdb之后的状态被执行
manage.py flush
returns the database to the state it was in immediately after syncdb was executed
C。创建模型中定义的所有表?
C. Create all tables as defined in the model?
manage.py syncdb
为INSTALLED_APPS中的所有应用程序创建数据库表其表格尚未创建。
manage.py syncdb
Creates the database tables for all apps in INSTALLED_APPS whose tables have not already been created.
请参阅此页面以获取所有命令的参考: https://docs.djangoproject.com/en/dev/ref/django-admin/
See this page for a reference of all commands: https://docs.djangoproject.com/en/dev/ref/django-admin/
但是,您一定要研究使用 south 作为已经提到的人。这是管理您的数据库的最佳方法。
But you should definitely look into using south as someone already mentioned. It's the best way to manage your database.
注意: syncdb
已被弃用,有利于迁移,自Django 1.7。
N.B: syncdb
is deprecated in favour of migrate, since Django 1.7.
这篇关于什么是django命令删除所有表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!