Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to move a MYSQL database from one computer to another.
I did a dump file on the computer with the database, I created the database on the second
computer and duplicated the table definitions and checked it make sure they are the same many times. When I use Load data infile I get the duplicate'0' key primary error.
I am using Windows 10 pro MYSQL 5.7.9
This error might indicate that the table's PRIMARY KEY is not set to auto-increment.
Solution:
Check that there is a PRIMARY KEY set on your table, and that the PRIMARY KEY is set to AUTO-INCREMENT.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am trying to rename a column in a table in my DB. I already tried
ALTER TABLE TableName RENAME COLUMN OldColumnName TO NewColumnName
and i am getting an error reply saying - You have an error in your SQL syntax; Please whats the right syntax for this? Thanks.
Try using this syntax:
ALTER TABLE TableName CHANGE OldColumnName NewColumnName varchar(10) ;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have single use keys stored in a table column. I have a table which contains only unique keys which, once read and sent, must be deleted from table using an atomic operation.
How can I accomplish this?
I need to use Node.js in asynchronous way; it is cumbersome to run two queries(select, and delete) for each request using transactions.
I wish that Delete returned the key as well... that'd have been easiest.
MySQL version: 5.5.54
Write a Stored Procedure to do the SELECT .. FOR UPDATE and DELETE in a single transaction and returning the SELECT results. Then perform a single CALL from your client.
This is a possible duplicate of MySQL update output deleted which has no answer either.
The thing is that MySQL has not implemented such syntax yet. It is available in other DBs, but in MySQL you are most likely stuck with SELECT .. FOR UPDATE; DELETE ... inside of a transaction. I am afraid that in MySQL you might not have any better option yet.
Some other links:
In MariaDB 10.0.5 it is possible to return values from
DELETE
OUTPUT
Clause in MySQL
In
mysql can I return deleted rows after a
deletion?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Does the order matter, when calling DROP TABLE IF EXISTS <some table> at the top of a SQL script?
If you are concerning about foreign keys, then you should first drop child tables. You can not drop a table if it is referenced in another table. But it's easier to temporarily disable key checks.
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE ...;
...
DROP TABLE ...;
SET FOREIGN_KEY_CHECKS = 1;
Then you won't need to care about the order of table drops.
Note that when you enable the key checks, the schema should be "clean" - There should not be any foreign key reference to a not existing table. Otherwise SET FOREIGN_KEY_CHECKS = 1 will fail.
Yes, if you call DROP TABLE IF EXISTS.... after script it will delete already created new table, what most probably you don't want to.
If you call DROP TABLE IF EXISTS.... before, you make sure that your script won't fail, if the table already exists
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I'm having an MYSQL error when someone registers, not everyone though, only for some users. Why is that?
Error:
SQL ERROR: 1062 Duplicate entry 'Fedot_Pulemiot' for key 'username'
To avoid duplicate entry we can add unique constrain to the column, sql as follows
ALTER TABLE `user` ADD UNIQUE(`user_name`);
But in your case i think already unique is set so drop the unique value as follows
ALTER TABLE tb_name DROP INDEX user_name;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
with "drop table if exists student"
without "drop table if exists student"
So,I connected the database to amazon rds.
I want to find the way to avoid the error without using "drop and flush".
I've spent few days to find the solution, but i haven't found any.
Thanks for all your help!
I think what you are looking for is CREATE TABLE IF NOT EXISTS Student.
For the whole mysql create table Syntax look at the official documentation