Solved

PHP/Mysql: Drop Column

Posted on 2007-11-30
2
834 Views
Last Modified: 2013-12-12
I am doing this:

mysql_query("ALTER TABLE model DROP COLUMN Column1");

but it says:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'column='Column1'' at line 1

But if i check the table, the column does get removed though...

0
Comment
Question by:jtcy
2 Comments
 
LVL 17

Accepted Solution

by:
nplib earned 250 total points
ID: 20383001
You've got an error in another sql statement, probably one that runs after that column gets removed and tries to reference the removed column.
0
 
LVL 50

Assisted Solution

by:Steve Bink
Steve Bink earned 250 total points
ID: 20385671
I'm with nplib.  You'll have to narrow down when the error is coming back, and which query is causing it.  The manual has this to say about altering tables:

>>> In most cases, ALTER TABLE works by making a temporary copy of the original
>>> table. The alteration is performed on the copy, and then the original table is
>>> deleted and the new one is renamed. While ALTER TABLE  is executing, the
>>> original table is readable by other clients. Updates and writes to the table are
>>> stalled until the new table is ready, and then are automatically redirected to
>>> the new table without any failed updates.

If you have other updates or writes going on in the background (for example, on another httpd thread using the same database), those queries will be delayed until the ALTER TABLE is finished.  When they do run, they will on the new version of the table.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now