8

When I'm adding a Virtual Layer to a project using QGIS 3.12.2, it cannot be toggled to edit mode. That is: the pencil icon is grey coloured. This can be said for layers created either by the Create Virtual Layer or the DB Manager SQL query.

Is it possible to edit a Virtual Layer? If so, how can it be done? If not, is there any documentation or reference regarding this aspect?

4
  • 1
    The doc implies that it is not possible to edit a virtual layer by saying Virtual layers do not carry data by themselves and can be seen as views
    – JGH
    Apr 24, 2020 at 11:50
  • IMHO ... Virtual Layer is not editable
    – Taras
    Apr 24, 2020 at 11:54
  • it's all about being clear ... do u want to edit the content of the layer (=the result of the query) or edit the definition of the layer (=the query itself) which is of course possible ...
    – Snaileater
    Apr 24, 2020 at 12:03
  • Hi @snaileater, I meant toggle editing the content of the virtual layer.
    – EranGeo
    Apr 24, 2020 at 12:22

2 Answers 2

13

No, you can not edit a virtual layer this way. This is because a virtual layer is just a query on other layers. So you either need to edit the layers the virtual layer is based on, or save the virtual layer as a "static" file - once you have done this, you can edit that no-longer-virtual-layer.

You can only edit the query of this virtual layer.

9

To complete the other answer

If you edit the source layer the virtual layer should update. If you use a database as a source you may create an editable view (see this question for exemple) but keep in mind that you are still modifying the original data and not only the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.