David Blomstrom <[EMAIL PROTECTED]> wrote on 03/24/2005 12:28:53 AM:
> I was trying to imnport a csv file into an online > databse table, but I kept getting error messages > alluding to a "child row," foreign key, etc. So I > decided to delete both keys (primary and index), then > import the csv file. > > I finally managed to delete the primary key, but I > can't zap the index. When I try to delete the field > itself, I get this error message: > > #1025 - Error on rename of > './geoblue_gypsy/#sql-bb1_1e763' to > './geoblue_gypsy/counties' (errno: 150) > > When I try to delete the primary key, I get this > message: > > #1025 - Error on rename of > './geoblue_gypsy/#sql-bb1_1e782' to > './geoblue_gypsy/counties' (errno: 150) > > So how do I get rid of it? > > Thanks. > > > > __________________________________ > Do you Yahoo!? > Yahoo! Small Business - Try our new resources site! > http://smallbusiness.yahoo.com/resources/ > For future reference, to get more information about an "errno: 150" use SHOW INNODB STATUS. If I had to guess, I would say that the detailed error message will say something to the effect that you can neither delete nor un-index a column that is participating as either end of a foreign key. My question to you: Why are you not using a staging table to import your csv file? What I mean by a "staging" table is a special table created especially for the purpose of receiving the raw, imported data. That gives you the opportunity to "fix" any problems in the data _before_ you try to merge it into your production data. You then use the data from the staging table (once you have checked it over and corrected any problems or filled in any missing information) as the data source for INSERT or UPDATE statements to get it into the tables where you want it to be. Once you are through with it you can either DROP your staging table or keep it around for the next batch of data. If there is one thing I have learned in this business it is to rarely ever trust "outside" data. Always verify it before you try to use it. Shawn Green Database Administrator Unimin Corporation - Spruce Pine