Some details about PostgreSQL layers
Da Wikipedia, l'enciclopedia libera.
Il testo inglese è tratto dal
sito ufficiale.
Come collaborare alla traduzione
Questa sezione contiene alcuni particolari su come QGIS accede ai livelli di PostgreSQL. Principalmente QGIS dovrebbe fornirvi semplicemente una lista delle tabelle del database che possono essere caricate, e caricarle a richiesta. Tuttavia, se avete difficoltà a caricare una tabella di PostgreSQL in QGIS, le informazioni qui sotto possono aiutare a capire tutti i messaggi di QGIS ed a darvi un'indicazione su come cambiare la definizione di tabella o di vista di PostgreSQL per permettere a QGIS di caricarla.
QGIS richiede che gli strati di PostgreSQL contengono una colonna che può essere usata come chiave unica per lo strato. Questo significa solitamente che la tabella ha bisogno di una chiave primaria o presenta una colonna con un vincolo unico su esso. QGIS richiede inoltre che questa colonna sia di tipo int4 (un numero intero del formato 4 byte). Se una tabella manca di questi articoli, la colonna oid sarà usata al suo posto. Le prestazioni saranno migliorate se la colonna è indicizzata (nota che le chiavi primarie sono automaticamente indicizzate in PostgreSQL).
Se lo strato di PostgreSQL è una vista, esistono gli stessi requisiti, ma le viste non hanno chiavi primarie o colonne con i vincoli unici su di loro. In questo caso QGIS proverà a trovare una colonna nella vista che provenga da una colonna della tabella appropriata. Se non se ne può trovare una, QGIS non caricherà il livello. Se questo accade, la soluzione è di alterare la vista in modo che includa una colonna adatta (un tipo di int4 e una chiave primaria o un vincolo unico, spostato e preferibilmente indicizzato).
This section contains some details on how QGIS accesses PostgreSQL layers. Most of the time QGIS should simply provide you with a list of database tables that can be loaded, and load them on request. However, if you have trouble loading a PostgreSQL table into QGIS, the information below may help you understand any QGIS messages and give you direction on changing the PostgreSQL table or view definition to allow QGIS to load it.
QGIS requires that PostgreSQL layers contain a column that can be used as a unique key for the layer. For tables this usually means that the table needs a primary key, or have a column with a unique constraint on it. QGIS additionally requires that this column be of type int4 (an integer of size 4 bytes). If a table lacks these items, the oid column will be used instead. Performance will be improved if the column is indexed (note than primary keys are automatically indexed in PostgreSQL).
If the PostgreSQL layer is a view the same requirements exist, but views don't have primary keys or columns with unique constraints on them. In this case QGIS will try to find a column in the view that is derived from a table column that is suitable. If one cannot be found, QGIS will not load the layer. If this occurs, the solution is to alter the view so that it does include a suitable column (a type of int4 and either a primary key or with a unique constraint, preferably indexed).

