0

I have an exercises table with this schema:

CREATE TABLE exercises
(
    id INTEGER NOT NULL,
    name VARCHAR(255) NOT NULL,
    workoutID INTEGER NOT NULL,

    FOREIGN KEY (workoutID) REFERENCES workouts(id)
);

I want to delete the column workoutID but it won't let me delete it:

sqlite> ALTER TABLE exercises DROP workoutID;

Error: near "DROP": syntax error

Upon realizing I need to remove the constraints first I try:

sqlite> ALTER TABLE exercises DROP CONSTRAINT workoutID;

Error: near "DROP": syntax error

I followed this question to the letter: How to drop column with constraint? But it doesn't work for me.

I can start over by dropping the whole table if I have to but I want to learn why this isn't working for me.

Any help and explanation is greatly appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Funlamb
  • 551
  • 7
  • 20
  • https://stackoverflow.com/questions/1884787/how-do-i-drop-a-constraint-from-a-sqlite-3-6-21-table – OldProgrammer Jan 15 '22 at 21:23
  • Thank you so much. I have been dropping tables for a month now because I couldn't find a way to do this. I finally asked the question because I knew there had to be a way. Can you change your comment to an answer so I can approve it as an answer? – Funlamb Jan 15 '22 at 21:25

0 Answers0