I am unable to edit my table in MySqL Query Browser.
I have the primary key defined, but I am still unable to edit.
Is there anything else that I need?
Thanks
Things to check:
does your user have write access to this table?
does the primary key column is shown in your query?
does your query is showing fields present in only one table?
Related
I have in Microsoft Access a linked table to an ASE Server.
On the server side, the table has no primary key or identity columns.
And has a trigger on insert that validates new entries, so that when the entry is not validated it deletes the entry from the table and writes to "table"_ERR to let the users know what error was produced.
When linking it to Access a composite key is created using 10 columns.
I have this same setup in 10 different tables (all with triggers all linked to Access)
In this particular table when trying to insert/append records to the table through Access i always get the error message:
Single-row update/delete affected more than one row of a linked table. Unique index contains duplicate values.
This error occurs when both table and table_ERR are empty and i'm only trying to insert 1 record.
If I disable the trigger i have no problem inserting records through Access
I have similar triggers in other tables that are working correctly.
What can be causing this issue and does anyone know how to solve this?
I have read that MS Access can mess up the ##identity, even so none of the solutions presented online seem to work.
links : https://groups.google.com/forum/#!msg/microsoft.public.sqlserver.programming/McHdRpPKMhs/SlyObU8w7JMJ
Stop Access from using wrong identity when appending to linked table on SQL server
Thanks in advance.
EDIT: if i try to insert the records directly from a management software (like Aqua Data Studio) there are no erros
Without knowing more specifics about your data itself, it is difficult to say why this might be happening.
However, it sounds like in this specific instance for this specific linked table, your 10 columns are not unique enough to prevent non-distinct rows from being selected.
Suggested fixes:
Add a primary key. Honestly, probably the best and easiest choice.
If for some reason you cannot add a new column to (or alter) your table; you may be able to re-link your table, and re-choose your 10 columns so that they are more unique.
Beyond that, I think we would need more information.
Just out of curiousity, what is the reason for having no key?
I know there is similar questions that are answered but please try to help me out.
I'm importing a backup of my MyBB database into a new host using PHPMyAdmin. When trying to import the .sql file, I get the following error:
SQL query:
INSERT INTO mybb_datacache( `title` , `cache` )
VALUES (
'internal_settings', 'a:1:{s:14:\"encryption_key\";s:32:\"rrvohvVATtOauucNTmEXAmvNvbw9ujvb\";}'
);
MySQL said:
#1062 - Duplicate entry 'internal_settings' for key 'PRIMARY'
I can't figure out the problem. I emptied all tables and clean install of the database four times already. I've been trying to figure this out all day and it's very frustrating.
(link removed)
Please help me out. How do I fix this problem?
When you export your sql from php admin
Select "custom" as export method"
then, instead of 'insert', choose "update"
This will perform update-statements and prevent duplicated inserts.
Make sure the column set as your PRIMARY KEY is set to AUTO_INCREMENT
From the current version of the question, it appears that the title column of the mybb_datacache table is the Primary Key and already has a record with the value 'internal_settings' in it. If this is indeed the case, then the problem is that all records must have unique values for their Primary Key.
I had this problem, and i found what the problem is.
The thing is that, the field cannot be empty. ie, if you are altering a table to add primary key, make sure you have some values in that field. or if u are importing a sql file, make sure that that field in the file has some values....
this solved my problem...
I need to insert new row into table foo. But before insert those data, I need to check there was already inserted a row for the respective user name. If there has been already inserted, then I need to update the current data with the new data.
I know to do this using PHP if condition. But I love to do this using MySQL functions/statements by just a one line. Please can anyone help me?
For the example, kindly use the following statement. It should be updated.
$in = "insert into foo(username, text) values('user-x', 'user-x-text')";
Mysql_query($in);
When searching for similar questions, I got this post: Similar question with an answer. But I was struggle to use that solution since I don't know, the process occur by that code snippet will get down the server resources like speed etc. Because this script will run about 20 times per user.
Thank you.
I think INSERT ... ON DUPLICATE KEY UPDATE should be able to work
Make username a UNIQUE index, it doesn't have to be a primary key
If I'm not mistaken, DUPLICATE KEY will run only when you have a collision in any of the columns you supply that is either a primary key or unique index. In your case, text column is neither so it will be ignored for collisions.
INSERT... ON DUPLICATE KEY UPDATE works on unique indexes as confirmed by the MySql docs
Is that possible?
I know how to do it with a program but is there any query to do it without the support of primary or foreign key?
In MySQL I don't think it is possible. If the MySQL user running query has the DELETE privilege, then they will be able to delete any row.
I have a table that is in production. I realize that some of the columns should be unique. Is it safe to go into phpMyAdmin and change those columns to make it unique?
ALTER TABLE `foo` ADD UNIQUE ( `bar` )
Follow the below steps to apply unique column value from phpmyadmin panel:
Go to the table structure. Click on the unique keyword as like below -
Click on the ok from confirmation box -
Unique value constraint for column will apply.
Or you can run mysql query:
ALTER TABLE user ADD UNIQUE(email);
You do not have duplicates -> will apply the key without issues
You do have duplicates -> will give an error message, nothing happened to your data
All is unique, except several rows with NULL in them, unique constraint is still applied, as NULL is not checked when checking for unique values (you can have the entire table have a NULL value in a unique field without any error message).
One more thing, if you have a prod DB, you must also have a dev DB which you can test on without fear, right?
If there are already some duplicate values in those columns, then this will generate an error. If there aren't any duplicate values in those columns, then you will be fine.
It will only be a problem if the pre-existing values on the table are not unique, otherwise I don't think there will be any problem.
I had this problem and my values were not unique. I also couldn't find an easy way to edit this problem in PHPMyAdmin. Here's how I solved it:
I clicked into the table I needed to update
I exported the table, changing it to be a CSV export and then edited
it manually to update the non-unique values.
Making sure I was still in the table I had exported (because I
wanted to keep the headers intact), I imported my newly saved CSV
Hope that saves someone some time in the future.