24

Can anyone tell if there is a difference between

>manage.py flush  # or reset

and

>manage.py sqlclear appname | python manage.py dbshell
>manage.py syncdb 
Jibin
  • 3,054
  • 7
  • 36
  • 51

2 Answers2

19

flush will truncate (delete data)

sqlclear will drop (delete table, thus data too)

=> if you have structural modifications in your db, you have to do sqlclear (but better use south)

Update:

South has been deprecated.

From Django 1.7 upwards, migrations are built into the core of Django. If you are running a previous version, you can use South.

Jeril
  • 7,858
  • 3
  • 52
  • 69
lajarre
  • 4,910
  • 6
  • 42
  • 69
  • https://docs.djangoproject.com/en/1.5/ref/django-admin/#sqlclear-appname-appname says: "Prints the DROP TABLE SQL statements for the given app name(s).". Seems to me it doesn't actually drop the tables. – peetasan May 22 '15 at 10:30
  • Read "will print statements to drop" then. Refer to the OP question to see how to actually apply the statements. – lajarre May 22 '15 at 11:00
5

Official docs for

flush and sqlclear

Flush carries out the SQL Drops on the entire db, sqlflush only prints out the SQL that flush would actual run (again on the entire db). sqlclear prints out SQL Drops for a particular app or apps. Both flush and sqlflush/dbshell/syncdb will install fixtures.

akki
  • 2,021
  • 1
  • 24
  • 35
Timmy O'Mahony
  • 53,000
  • 18
  • 155
  • 177
  • 1
    by running sqlflush, looks like flush would only truncate tables rather than drop them. – Bobo Oct 02 '12 at 15:25