Professional Documents
Culture Documents
Christina Robinson
Contents
Introduction
The server should now be shown in the left hand box and you can navigate your way round your
database tables. To query the data within these tables an SQL query is necessary, clicking the SQL
icon will produce another window in which the query should be written.
SQL icon
Below is screen shot of the SQL window where the queries are written.
INSERT
means escape
\\
::
|| ||
WHERE
SELECT
UPDATE
CREATE VIEW
SRID
Spatial Reference ID
centroid
used to identify value that begins with or ends with a certain suffix (785%)
LIKE
IS NULL
NOT NULL
AND
lets you join tables together with matching values and also always to have
multiple conditions
CREATING VIEWS:
These are to create views from pgAdmin that then can be loaded into QGIS.
CREATE VIEW view name AS SELECT * FROM table heading WHERE column heading = value
When creating a view you also need to create permissions so that the views can be updated via
the GIS. These are the permissions you need:
ALTER TABLE <table name> OWNER TO <database>
GRANT ALL ON TABLE <table name> TO <database>
GRANT SELECT ON TABLE <table name> TO <backup>
GRANT SELECT, UPDATE, INSERT ON TABLE <table name> TO <database>
There are also rules which need to be added, again, so editing of the views can take place within
the GIS (this will also edit the information in the database).
CREATE OR REPLACE RULE (rule name) AS UPDATE TO <table name> (view name) DO
INSTEAD UPDATE <table name> SET <column heading> = <new tbl>.<new column>
and
CREATE OR REPLACE RULE name of rule AS ON UPDATE TO name of view DO INSTEAD UP
DATE table where geom stored SET the_geom=new.the_geom WHERE table where geom
stored.OID=new.OID
To upload these views that have been created into QGIS please take a look at the QGIS handy
hints here: http://library.thehumanjourney.net/657/