Kumar Ravi Singh
Kumar Ravi Singh

Reputation: 181

phpmyadmin : created view from multiple table now id field is not unique can't edit,update delete

Getting Error:

Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

How can I get a unique field in a view generated from multiple tables?

Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.

Upvotes: 0

Views: 354

Answers (1)

vhu
vhu

Reputation: 12818

This is more general than just phpmyadmin, but there are some restrictions on "Updatable and Insertable Views". Here is the gist:

For a view to be updatable, there must be a one-to-one relationship between the rows in the view and the rows in the underlying table.

Then more specifically on the multiple-table views:

It is sometimes possible for a multiple-table view to be updatable, assuming that it can be processed with the MERGE algorithm. For this to work, the view must use an inner join (not an outer join or a UNION).

There are additional restrictions,which prevent update/insert even on a single table views:

To be more specific, a view is not updatable if it contains any of the following:

  • Aggregate functions (SUM(), MIN(), MAX(), COUNT(), and so forth)

  • DISTINCT

  • GROUP BY

  • HAVING

  • UNION or UNION ALL

  • Subquery in the select list

  • Certain joins (see additional join discussion later in this section)

  • Reference to nonupdatable view in the FROM clause

  • Subquery in the WHERE clause that refers to a table in the FROM clause

  • Refers only to literal values (in this case, there is no underlying table to update)

  • ALGORITHM = TEMPTABLE (use of a temporary table always makes a view nonupdatable)

  • Multiple references to any column of a base table

Upvotes: 1

Related Questions