Basically mistyped a migration and now I have a column in my users table like this: {:index=>true}_id
I am trying to remove this field in MYSQL terminal with:
ALTER TABLE 'users' DROP COLUMN '{:index=>true}_id';
Error message:
ERROR 1064 (42000): 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 ''users' drop column '{:index=>true}_id'' at line 1
You need to use backticks instead of single quotes.
ALTER TABLE `users` DROP COLUMN `{:index=>true}_id`;
Related
I am trying to remove Unique constraint from a column using flyway DB migration in spring-boot. But I am not able to figure out the right query for that. Here is my existing query
ALTER TABLE `choices` DROP UNIQUE `UK6i9q4suadww4j167aqe2h6aqj`;
Here is the error
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 'UNIQUE `UK6i9q4suadww4j167aqe2h6aqj`' at line 4
Note: the above query is working fine if I am running it through PHPMyAdmin. Its ask for confirmation and then remove it.
Use
ALTER TABLE `choices` DROP index `UK6i9q4suadww4j167aqe2h6aqj`;
This will only work , if there in no foreign key defined that references your key.
.
In which case you have to drop the foreign keys first.
What is wrong with my syntax?
I'm trying to update several databases in one shot:
update `db_name1`.`db_table` SET `cc_number_enc` = NULL
update `db_name2`.`db_table` SET `cc_number_enc` = NULL
update `db_name3`.`db_table` SET `cc_number_enc` = NULL
and I'm getting query syntax error in phpmyadmin
1064 - 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 'cc_number_enc = NULL' at line 1
UPDATE
I've rewritten the same query simply by copying & pasting, and now getting the following:
1064 - 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 'cc_number_enc = NULL' at line 1
Question, is it matter from which database I'm running the query from in phpmyadmin?
try puting semicolon after query. It can happen because of multiple reasons.
references http://www.inmotionhosting.com/support/website/database-troubleshooting/error-1064
MySQl Error #1064
MySQL Nested Queries with Joins
Looks like when copying, your backticks are changed to some other symbol, which looks like backtick, but actually, it is not.
Try again without quotes, or manually put backticks in place.
I tried using this in mysql:
INSERT INTO users (url) VALUES (http://31.media.tumblr.com/tumblr_ljtc6i9GPA1qbq4v6o1_400.gif) WHERE id='15';
But it gives this error:
"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 '://31.media.tumblr.com/tumblr_ljtc6i9GPA1qbq4v6o1_400.gif) WHERE id='15'' at line 1"
Can anyone tell me what is the reason and how to store the url in the table?
INSERT INTO statements don't have a WHERE clause. If you are wanting to use a WHERE clause you are just UPDATEing a row.
UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;
i have just make a table as Customer 1,
& now want to Drop that, so used DROP TABLE Customer 1. but my sql shows,
You have an error in your SQL syntax 1064. i tried multiple combinations of above command, but still unable to do so.
Error - #1064 - 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 '1' at line 1
The issue here is likely to be the space in the table name. Have you tried the following?
DROP TABLE `Customer 1`;
I am trying to drop tables with wp_ prefix but its giving error below
Error 1064: 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 'WHERE TABLE LIKE 'wp_%'' at line 1
Here is my query
"DROP TABLE WHERE TABLE LIKE '{$wp}%'"
What is wrong in this query? Please help
As far as I know, you can't selectively delete tables. You have to specifically delete each table, since deletion can't use a filter. You could probably use the metadata to get the names of all of your tables, and then find out in your code which ones start with wp_. Then, you would just loop through your list of tables to delete and then delete them with drop table [table-name];.
To get the list of table names from metadata, use select table_name from information_schema.tables;.