Why i cannot delete data in phpmyadmin - database

I just want to delete one record from this table. So, i click delete button but it show this error.

You specified a WHERE statement, but you didn't execute any term. Either remove the WHERE statement (which deletes a random item from the table (thanks #DanFromGermany) or add the term
if you clicked on the delete link, try to check the row before

A possible cause for this behaviour is when you fire a query that does not include a primary key in the output. phpMyAdmin then does not know which column identifies a selected row.
Can you verify this?
Another thing is, your phpMyAdmin looks outdated, can you try the same thing with an up to date version?

Related

how to copy structure and data with specific column in visual foxpro

Please help, I have large database in DBF where have 34 column and more than 50k record.
In this case, I need 10 column only from 34 column. Logically, if I delete not necessary column will reduce data load.
So I will copy structure and data from source file with specific column, but I do not know how to do it in visual foxpro.
Will you help me for this case ?
Before and after, thanks for your attention to read my problem.
Regards,
Pathic
Use the following syntax:
SELECT col1,col2,col3,col4,col5,col6,col7,col8,col9,col10 FROM table1 INTO TABLE table2
If you only want to REMOVE the column PERMANENTLY, first, for grins, make a backup copy of the file. Then, make sure you are out of any program using that table and start VFP. In the command window, enter
USE C:\SomePath\YourTable EXCLUSIVE {enter}
*/ Now, get the one column you want copied out... you can just add as many
*/ Columns, such as any primary key reference you may also want to include to.
COPY TheOneColumnYouWant to C:\SomePath\NewTableForThisColumnOnly {enter}
*/ Now, to remove the column from the original table, now that is has been moved
*/ to the "other" table.
MODIFY STRUCTURE {enter}
This brings up a modify table structure where you can alter / delete ANY column. Scroll down the list to the column you want to delete, and at the bottom, click the DELETE button, then click the OK button to confirm structure changes. It will then come back with a confirmation prompt to "Make structure changes permanent?" and select Yes. Column now gone.
An alternative to deleting columns in VFP, you can use Alter Table via...
ALTER table C:\SomePath\YourTable DROP COLUMN TheOneColumnYouWant

Many to many relations and history tables

Suppose I have Item and Tag, each of which have an id and name column only, and an Item_Tag_Map table that has a composite Item.id, Tag.id primary key.
If I want to implement a history table for Item and Tag, this seems relatively straightforward - I can add a third column revision and a trigger to copy into an ItemHistory or TagHistory table with id, revision as primary key and operation ("INSERT","UPDATE",etc). Since I may want to "delete" items, I can go about this one of two ways:
Add another column on Item or Tag for is_active, and do not actually delete any rows ever
Delete rows, but record the deletion in the history table as a delete operation, and on an Item or Tag insert, make sure to get the latest revision number from the ItemHistory or TagHistory table with that item, and set it to be that
The second option leaves a bad taste in my mouth, so I am fine with using the first. After all, why should I really ever need to delete an item when I can just modify it or change its active status?
Now, I've run into the same problem for the history table on the Item_Tag_Map table, but this time, neither option seems all that attractive. If I choose to add an is_active for the Item_Tag_Map, the logic of finding out whether a tag is mapped to an item changes from:
Get ALL tag_mapping for THESE items
to
Get ALL tag_mapping for THESE items WHERE is_active
The implicit idea that the presence of a mapping means that the mapping exists goes away. The set of unmapped item-tags not only includes all the ones that are not present in the table, but also the ones where is_active is false.
On the other hand, if I choose the second option, it's still rather ugly.
I'm sure people have run into this problem many times before, and I am interested in learning how you have dealt with it.
My answer depends on a few things, so I'll try to state my assumptions.
No matter what I think is_active on Item and Tag are ok. If the record size grows very fast on those two entities, then consider running a nightly job to move the inactive records to an archived version of the tables. This can be used for reporting or auditing of things later. You can also write a script to restore records if you need, but the idea is that your real time tables are fast and without deleted data.
If you allow the user to add/update/delete mappings, then I would consider the table the same as Item and Tag. Add the flag and use it in your queries. It doesn't seem ugly to me - I've seen it before.
If the mapping table isn't under user control, then I would guess you would use the is_active flag on either Item or Tag to determine whether or not a query could be run.
Just know that once you add that flag, people will forget to use it. I know I've done it many times, ("Why did I get so many records, what am I missing? Oh yeah, is_active...)

Deleting a single row from a table that has multiple entries?

So here's my situation.
I have a table in my database, it has multiple entries, but I need only one to be deleted.
When trying to google this, all I could find was questions referring to deleting all except one of these entries, while I need to delete ONLY ONE and leave the rest.
I'm completely confused on this, and don't really understand how to do it.
You need to use a where clause to identify the row that you want to delete, preferably by the primary key of the table. For example:
delete from MyTable where id = 1
If you post your table's schema, we can help with better syntax.
The row you are trying to delete should have a unique way to identify it, typically the primary key. You would then use the WHERE clause to specify your query to DELETE it:
DELETE FROM sparkles WHERE primaryKey = 1
Alternatively, if there are no keys, you would filter by criteria that matches all values of the record you wish to delete.
DELETE FROM sparkles WHERE col1 = 5 AND col2 = 15 AND col3 = 51
If you are trying to achieve this in Java, you would most probably be using JDBC however if this is just a onetime effort you can directly run the delete query with appropriate where clause.
Well I don't see how this is tagged as Java. But it sounds like you want to use limit operator, like this:
DELETE FROM somedatabase WHERE someentry = 5 LIMIT 1;
The response two above me is good to but leaves out LIMIT.
Step by step for doing it in phpMyAdmin....
Go to phpMyAdmin interface
Select the database
Select the table
Click Browse
Look for the row you are looking to delete and click the delete Icon
Confirm deletion of that row
Done.
If you have 5 Fields in table and you want to delete only one field for particular instance then you should fire update query giving the null effect to that filed...
Suppose If table is
Id | Name | MobNum
And you want to delete MobNum of record 5 ...then query can be ike this>>>
update tlbName set MobNum=null where Id='5'

postgresql and django - No unique identifier for this row

Two entries on my Django postgresql database are causing me a world of trouble when I go a-querying to create reports. When I try to delete these entries (via phpPgAdmin), I get the error "No unique identifier for this row." There are no duplicate IDs. I've tried updating all the fields. I've tried getting rid of these using the delete button and manual SQL commands. I'm out of ideas. Anyone know hot to give a row a unique identifier so I can get rid of it?
Thanks!
Look up the row by the special ctid system column and then delete by that value. ctid's are unique.
The rows you are going to delete may be referenced in another table.
remove them or refer them to something else and, then try to remove your given rows.

Unable to change Identity Specification to Yes in Sql Server table

This may be a dumb question, but why can't I change the Identity Specification or (Is Identity) from 'No' to 'Yes'?
Check your column data type.
If it is varchar then you can't change identity column.
To change identity column, it should have int data type.
You can disable the Option "prevent saving changes that require table re-creation"
but this is strongly unrecommended by msdn.
to do so go to:
Tools -> Options -> Designers
There uncheck: "prevent saving changes that require table re-creation"
You cannot change the IDENTITY property of a column on an existing table. What you can do is add a new column with the IDENTITY property, delete the old column, and rename the new column with the old columns name.
Of course, what happens then (for some people) is that they don't like the fact that the new column appears "at the end" of the list of columns (even though you shouldn't care about the positions of columns - you should always be using their names). In that case, you need to do the same trick, but at a higher level - create a new table (with the column definition altered), copy data from the old table to the new, drop the old table, and rename the new one.
I thought SSMS still tried to pretend that it was possible, by doing the second trick behind the scenes.
Also check to make sure that there isn't a default value or binding on the column.
Remove Default Value or Binding.
Following on from Damien_The_Unbeliever's comment above, you can edit the column order in Visual Studio's design interface.
I've managed to do this successfully. To confirm, the steps are:
Add a new column with the IDENTITY property
delete the old column,
Rename the new column with the old columns name.
(Optional) Re-order columns to have the IDENTITY column from Visual Studio.
The solution that worked for me was to change the Data Type to int from its default nchar. Additionally, I had to refresh my database server connection to get it working.
As you can see the yes value for the identity specification is disabled so the other answers above is not applicable for me but following Joy's answer, I saw that I really had a Default Value or Binding. I just omitted the default value and everything i neede was enabled.
Took me a while to find the solution to this, at first I was trying to find a way to change a value from here (it's yes cause I was able to change it using the next way)
But then by right-clicking -> properties -> Table designer -> Choose Identity column
Doing this made the "Identity Specifiacation" to "Yes"
I think Firstly you have to check the (isIdentity) checkbox after that you can able to check the Identity Specification Checkbox

Resources