0

In pset 7 CS50 Finance I have a problem where new rows are not being added to my data tables Portfolio and History, and I think the reason is that I set the id column to be the Primary Key. So, now I wonder how to uncheck the primary key option. When I try to edit my table in phpLiteAdmin I am not able to edit the primary key. Just the field name and data type are editable.

Do I need to just delete the column and make a new one with the same name, and not check the primary key option? Or do I need to write some SQL statement?

Also, for some reason I think I set the id column to auto increment when I made the table. I guess that would be wrong too, so I also need to uncheck that option as well.

Any help would be appreciated!

1 Answer 1

0

There are any number of ways to do what you want. You can use the phpliteadmin interface, go to the table, select the structure tab and delete the desired index.

Or you could create and run an SQL command to "ALTER TABLE tablename DROP PRIMARY KEY;"

Or you could just delete the table through the interface or via SQL command and recreate it the way you want it. Hint: You might want to generate the SQL command to create the current table using the interface first. Then, you could edit the command to remove the parts you don't want, and use it to recreate the table.

Note that if there are any dependencies on the table (like foreign keys, etc.), those dependencies may need to be removed first. It's unlikely that you have any though.

Like I said, lots of ways to do these things. All these suggestions also apply to the auto-increment issue. Remember, too, that google is your friend in figuring out SQL commands.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .