0 Replies - 344 Views - Last Post: 16 August 2013 - 04:28 AM Rate Topic: -----

#1 Orochimaru  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 47
  • Joined: 26-December 12

How do you use dbshell ALTER TABLE correctly?

Posted 16 August 2013 - 04:28 AM

I found this example on a Stack Overflow webpage. But I'm not sure if I did things correctly?
$ python manage.py dbshell
> ALTER TABLE <appname_modelname> ADD COLUMN <column_type> DEFAULT '';



$ python manage.py sqlall navi_polls
CREATE TABLE "navi_polls_altword" (
        "rosword_id" integer NOT NULL REFERENCES "navi_polls_word" ("id"),
        "wordy_id" integer NOT NULL PRIMARY KEY REFERENCES "navi_polls_word" ("id"),
);

Is this the correct syntax? Because things at Django's built-in admin page doesn't behave 100% normal.
sqlite> ALTER TABLE navi_polls_altword ADD COLUMN "wordy_id" integer NOT NULL DEFAULT '';

When I try the entire thing I get the below error message. What am I doing wrong?
sqlite> ALTER TABLE navi_polls_altword ADD COLUMN "wordy2_id" integer NOT NULL PRIMARY KEY REFERENCES "navi_polls_word" ("id") DEFAULT '';
Error: Cannot add a PRIMARY KEY column


Is This A Good Question/Topic? 0
  • +

Page 1 of 1