Skip to content

Commit

Permalink
Merge pull request qgis#145 from astroidex/master
Browse files Browse the repository at this point in the history
added chapter for Oracle and some changes in PostgreSQL too
  • Loading branch information
dassau committed Sep 18, 2013
2 parents b6af994 + 31faced commit c98a82f
Showing 1 changed file with 94 additions and 13 deletions.
107 changes: 94 additions & 13 deletions source/docs/user_manual/working_with_vector/supported_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,16 @@ improved if the column is indexed (note that primary keys are automatically
indexed in PostgreSQL).

If the PostgreSQL layer is a view, the same requirement exists, but views
do not have primary keys or columns with unique constraints on them.
In this case |qg| will try to find a column in the view that is derived
from a suitable table column. It does this by parsing the view definition
SQL. However there are several aspects of SQL that |qg| ignores; these
include the use of table aliases and columns that are generated by SQL
functions.

If a suitable column cannot be found, |qg| will not load the layer.
do not have primary keys or columns with unique constraints on them. You have to
define a primary key field (has to be integer) in the QGIS dialog before you can load the view.
If a suitable column cannot does not exist in the view, |qg| 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
a suitable column (a type of integer and either a primary key or with a
unique constraint, preferably indexed).

QGIS offers a checkbox **Select at id** that is activated by default. This option
gets the ids without the attributes is faster in most cases. It can make sense
to disable this option when you use views.
gets the ids without the attributes which is faster in most cases. It can make sense
to disable this option when you use expensive views.

.. %FIXME: Add missing information
.. % When dealing with views, |qg| parses the view definition and
Expand Down Expand Up @@ -613,7 +608,93 @@ drop import support.
ORACLE Spatial Layers
---------------------

|mActionAddOracleLayer| QGIS also provides native ORACLE Spatial support. The
|mActionAddOracleLayer| QGIS also provides native ORACLE Locator/Spatial support. The
|mActionAddOracleLayer| :sup:`Add ORACLE Spatial Layer` is part of the new toolbar
button or available in the ORACLE node in the QBrowser tree, providing drag and
drop import support.
drop import support. ORACLE Spatial layers are stored in an ORACLE database.


.. index:: Connection_Manager

.. _vector_create_stored_oracle_connection:

Creating a stored Connection
............................

|mActionAddOracleLayer| The first time you use a ORACLE Spatial data source, you must create
a connection to the database that contains the data. Begin by clicking
on the |mActionAddOracleLayer| :sup:`Add ORACLE Spatial Layer` toolbar button, selecting the
|mActionAddOracleLayer| :menuselection:`Add ORACLE Spatial Layer...` option from the
:menuselection:`Layer` menu or typing :kbd:`Ctrl+Shift+O`. To access the
connection manager, click on the **[New]** button to display the
:guilabel:`Create a New ORACLE Spatial Connection` dialog. The parameters required for
a connection are:

* **Name**: A name for this connection. Can be the same as *Database*
* **Database** SID or SERVICE_NAME of the Oracle instance.
* **Host**: Name of the database host. This must be a resolvable host name the
same as would be used to open a telnet connection or ping the host. If the
database is on the same computer as |qg|, simply enter *'localhost'* here.
* **Port**: Port number the PostgreSQL database server listens on. The default
port is 1521.
* **Username**: User name used to login to the database.
* **Password**: Password used with *Username* to connect to the database.

Optional you can activate following checkboxes:

* |checkbox| :guilabel:`Save Username` Indicates whether to save the database user name in the connection configuration.
* |checkbox| :guilabel:`Save Password` Indicates whether to save the database password in the connection settings. Passwords are saved in clear text in the system configuration and in the project files!
* |checkbox| :guilabel:`Only look in meta data table` Restricts the displayed tables to those that are in the all_sdo_geom_metadata view. This can speed up the initial display of spatial tables.
* |checkbox| :guilabel:`Only look for user's tables` When searching for spatial tables restrict the search to tables that are owner by the user.
* |checkbox| :guilabel:`Also list tables with no geometry` Indicates that tables without geometry should also be listed by default.
* |checkbox| :guilabel:`Use estimated table statistics for the layer metadata` When the layer is setup various metadata is required for the Oracle table. This includes information such as the table row count, geometry type and spatial extents of the data in the geometry column. If the table contains a large number of rows determining this metadata is time consuming. By activating this option the following fast table metadata operations are done: Row count is determined from all_tables.num_rows. Table extents are always determined with the SDO_TUNE.EXTENTS_OF function even if a layer filter is applied. The table geometry is determined from the first 100 non-null geometry rows in the table.
* |checkbox| :guilabel:`Only existing geometry types` Only list the existing geometry types and don't offer to add others.

Once all parameters and options are set, you can test the connection by clicking on the **[Test Connect]** button.

.. _tip_settings_security:

.. tip:: **QGIS User Settings and Security**

Depending on your computing environment, storing passwords in your |qg|
settings may be a security risk. Passwords are saved in clear text in the
system configuration and in the project files!
Your customized settings for |qg| are stored based on the operating system:

* |nix|, the settings are stored in your home directory in :file:`.config/QGIS/QGIS2.conf`.
* |win|, the settings are stored in the registry.

.. _vector_loading_ORACLE Spatial:

Loading a ORACLE Spatial Layer
.......................

|mActionAddOracleLayer| Once you have one or more connections defined, you can load
layers from the ORACLE database. Of course this requires having data in
ORACLE.

To load a layer from ORACLE Spatial, perform the following steps:

* If the :guilabel:`Add ORACLE Spatial layers` dialog is not already open,
click on the |mActionAddOracleLayer| :sup:`Add ORACLE Spatial Layer` toolbar button.
* Choose the connection from the drop-down list and click **[Connect]**.
* Select or unselect |checkbox| :guilabel:`Also list tables with no geometry`
* Optionally use some |checkbox| :guilabel:`Search Options` to define
which features to load from the layer or use the **[Build query]** button
to start the :guilabel:`Query builder` dialog.
* Find the layer(s) you wish to add in the list of available layers.
* Select it by clicking on it. You can select multiple layers by holding
down the :kbd:`Shift` key while clicking. See Section
:ref:`vector_query_builder` for information on using the ORACLE
Query Builder to further define the layer.
* Click on the **[Add]** button to add the layer to the map.

.. _tip_ORACLE Spatial_layers:

.. tip:: **ORACLE Spatial Layers**

Normally an ORACLE Spatial layer is defined by an entry in the **USER_SDO_METADATA**
table.

.. _sec_ORACLE Spatial_details:

0 comments on commit c98a82f

Please sign in to comment.