Oracle Spatial 组件 说明

 

一.Spatial 组件说明

 

在之前整理了几篇与Oracle组件相关的Blog:

Oracle8i/9i/10g/11g组件(Components) 说明

http://blog.csdn.net/tianlesoftware/article/details/5937382

 

Oracle XDB 组件 重建 说明

http://blog.csdn.net/tianlesoftware/article/details/7323139

 

Oracle OLAP 组件 重建 说明

http://blog.csdn.net/tianlesoftware/article/details/7321333

 

在这篇我们看一下Spatial组件的说明。

 

在说明之前,我们先用如下SQL查看一下DB中的组件:

SQL> col comp_id for a15

SQL> col version for a15

SQL> col comp_name for a30

SQL> select comp_id,comp_name,versionfrom dba_registry

 2  ;

 

COMP_ID         COMP_NAME                      VERSION

--------------------------------------------- ---------------

XDB             Oracle XML Database            11.2.0.3.0

AMD             OLAP Catalog                   11.2.0.3.0

EM              Oracle Enterprise Manager      11.2.0.3.0

SDO             Spatial                        11.2.0.3.0

ORDIM           Oracle Multimedia              11.2.0.3.0

CONTEXT         Oracle Text                    11.2.0.3.0

ODM             Oracle Data Mining             11.2.0.3.0

EXF             Oracle Expression Filter       11.2.0.3.0

RUL             Oracle Rules Manager           11.2.0.3.0

OWM             Oracle Workspace Manager       11.2.0.3.0

CATALOG        Oracle Database CatalogViews  11.2.0.3.0

 

COMP_ID         COMP_NAME                      VERSION

--------------------------------------------- ---------------

CATPROC         Oracle Database Packages and T11.2.0.3.0

                ypes

 

JAVAVM         JServer JAVA VirtualMachine   11.2.0.3.0

XML             Oracle XDK                     11.2.0.3.0

CATJAVA         Oracle Database Java Packages  11.2.0.3.0

XOQ             Oracle OLAP API                11.2.0.3.0

APS             OLAP Analytic Workspace        11.2.0.3.0

 

17 rows selected.

--这里是我们DB 的所有组件列表, 其中有关OLAP 组件的说明,之前的Blog 已经说明,这里看一下Spatial 组件。

 

MOS上对该组件的说明如下:

Oracle Spatialis an extension to the Oracle RDBMS. An integrated set of functions andprocedures, that enables spatial information to be stored, managed andmaintained within Oracle. 

 

Oracle Spatialis designed to make spatial data management easier and more natural to users oflocation-enabled applications and geographic information system (GIS)applications. When spatial data is stored in an Oracle database, it can beeasily manipulated, retrieved, and related to all other data stored in thedatabase. 

--Oracle Spatial 组件是为了让空间数据管理更容易,更自然的使用location-enabled应用和GIS 应用。 当Spatial 数据存储在DB中时,它可以很容易的被操作和恢复,与之相关的其他数据也会存储在DB中。

 

It is an optionwhich provides integration of location with traditional relational attributedata for Internet and wireless location-based services. However, Oracle Spatialdoes not provide tools for spatial data collection, sophisticated analytical andvisualisation functionality provided by the traditional Geographic InformationSystems (GIS).

 

Oracle Spatial consists of the following:

(1)    A schema (MDSYS) thatprescribes the storage, syntax, and semantics of supported geometric datatypes.

(2)    Spatial indexing mechanisms.

(3)    A set of spatial operators andfunctions for performing area-of-interest queries, spatial join queries, andother spatial analysis operations.

(4)    Administrative utilities.

(5)    Java classes for accessing,manipulating and storing Spatial object types. This will be included in afuture distribution but is currently available from the Oracle TechnicalNetwork (OTN)

 

Spatial data isany data with a location component. Databases with geographic references, suchas addresses, phone numbers and postal codes may now analyse this informationusing third party geocoding tools and services. The Oracle Spatial geocodingfeature matches these records with a latitude/longitude point that is thenstored in the database. This facilitates analysis based on spatialrelationships of the associated data. The proximity of ATM machines tocustomers within a certain distance and the amount of money withdrawn perterritory are examples of geocoding feature usage.

 

A common exampleof spatial data can be seen in a road map. A road map is a two-dimensionalobject that contains points, lines, and polygons that can represent cities,roads, and political boundaries such as states or provinces. A road map is avisualization of geographic information. The location of cities, roads, andpolitical boundaries that exist on the surface of the Earth are projected ontoa two-dimensional display or piece of paper, preserving the relative positionsand relative distances of the rendered objects. 

--Spatial Data 一个常见的示例就是road map。Road Map 是一个二维的对象,其包含点,线和多变形,这些信息可以代表一个城市,街道或者城市和省的边界。Road Map 是地理信息的形象化。

 

Spatial 组件的用户:

(1)    MDSYS:

The Oracle Spatial and Oracle interMedia Locator administratoraccount 

(2)    MDDATA:

The schema used by Oracle Spatial for storing Geocoder androuter data 

 

更多说明参考官网手册:

http://docs.oracle.com/cd/B19306_01/appdev.102/b14255/toc.htm

What is Oracle Spatial? A Technical UserIntroduction [ID 102313.1]

 

二.Spatial 组件重建

MOS:

Master Note for Oracle Spatial and OracleLocator Installation [ID 220481.1]

 

2.1 Spatial 组件卸载

MOS:

Steps for Manual De-installation of OracleSpatial [ID 179472.1]

 

2.1.1 准备工作

Before deinstalling Oracle Spatial, it isbest to drop all Spatial indexes.

--在卸载OracleSpatial 组件之前最好drop 掉所有的Spatial 索引。

 

Check if Spatial indexes exist in thedatabase: 

--可以使用如下SQL来检查:

connect / as sysdba 
select owner,index_name from dba_indexes  where ityp_name ='SPATIAL_INDEX';

 

Check if tables having Spatial columns(columns having datatype SDO_GEOMETRY) exist:

--检查是否有表使用Spatial列,即列的类型为:SDO_GEOMETRY.

set pages 200 
col owner for a20 
col table_name for a30 
col column_name for a25 

/* Formatted on 2012/3/8 13:48:49 (QP5v5.185.11230.41888) */

 SELECT owner, table_name, column_name

    FROM dba_tab_columns

  WHERE data_type = 'SDO_GEOMETRY' AND owner != 'MDSYS'

ORDER BY 1, 2,3;

 

Note: Removing MDSYS will drop (!) existingSDO_GEOMETRY columns from above tables! 

--在我们卸载Spatial组件时,会drop 掉所有表中包含SDO_GEOMETRY的列。

 

如果存在SDO_GEOMETRY列,那么参考MOS文档处理:

Re-installing Spatial with Existing TablesHaving an SDO_GEOMETRY Column [ID 250791.1]

 

2.1.2 drop Spatial 索引

To drop Spatial indexes: 
SQL>drop index <owner>.<indexname>; 

--如果有索引不能drop,加force 强制drop:

-- If some indexes cannot be dropped usethe FORCE option: 
SQL>drop index <owner>.<indexname> force; 

 

2.1.3 drop Spatical 用户:MDSYS

Then drop the user MDSYS: 

SQL>drop user MDSYS cascade; 

 

2.1.4 drop 同义词

Optionally drop all remaining publicsynonyms created for Spatial: 

--可选的操作,drop剩余的同义词,语法如下:

set pagesize 0 
set feed off 
spool dropsyn.sql 
select 'drop public synonym "' || synonym_name || '";' fromdba_synonyms where table_owner='MDSYS'; 
spool off;
@dropsyn.sql

 

2.1.5 Drop 其他用户

Spatial alsocreates a few user schemas during installation which can be dropped aswell: 

       --Spatial 在drop 期间也会产生新的用户,这些用户也可以被drop:

 

SQL>drop user mddata cascade; 


-- Only created as of release 11g: 

--这些用户仅在11g中产生:

SQL>drop user spatial_csw_admin_usrcascade; 
SQL>drop user spatial_wfs_admin_usr cascade; 

 

2.1.6 其他注意事项:

(1)如果我们删除Spatial 后,还可以从v$option中查到记录,如:
SQL> select * from v$option where parameter = 'Spatial';
PARAMETER VALUE
------------------------------- ----------
Spatial TRUE

这个暂时没有没有解决方法,因为与Spatial 相关的表和索引我们之前已经droped,但是v$option 并没有更新,这个可能是Oracle 的BUG:

BUG:3069432 -V$OPTION NOT UPDATED AFTER DEINSTALLING SPATIAL OPTION

 

具体可以参考:

Removed Spatial Option But Spatial StillAppears In V$Option [ID 273573.1]

 

(2)必须安装Spatial 组件

如果我们卸载了Spatial 组件之后,又不打算重装Spatial 组件,那么我们至少必须安装Spatial 组件的一个子组件:Oracle Locator。 这样就可以避免以后升级中依赖关系带来的问题,比如XDB 组件。

 

(3)彻底清除Spatial 组件

如果Spatial 安装失败或者安装到其他用户下面,那么可以参考如下文档,直接drop 所有相关的对象来清除所有Spatial组件对象。

AccidentallyInstalled SPATIAL Into SYS, SYSTEM Or Another Schema [ID 413693.1]

 

 

2.2 Spatial 组件安装

MOS:

Steps for Manual Installation /Verification of Spatial 10g / 11g [ID 270588.1]

Steps for Manual Installation of Oracle 9iSpatial [ID 220484.1]

 

2.2.1 Oracle 9i 安装Spatial

       在Oracle 9i中,Spatial 组件是预选安装的,只要只要同意,就可以安装了。如果我们使用DBCA 来创建示例,Spatial 组件也是默认安装的。

       如果我们在创建实例时没有安装Spatial 组件,那么可以使用如下方法:

 

Oracle 9i 中的条件是初始化参数中的COMPATIBLE 参数值大于 9.0.0.0.0.

 

2.2.1.1 Check if the userORDSYS already exists:

--检查ORDSYS用户是否存在:

Connect to the database instance specifyingAS SYSDBA.

SQL> select username from dba_userswhere username='ORDSYS';

 

(1)If ORDSYS does NOT exist:

--如果ORDSYS不存在:

SQL> @?/ord/admin/ordinst.sql

 

This will createthe ORDSYS user and the MDSYS user with the required privileges.

The accountMDSYS will be locked by default by this script (in release 9.2 only).

这个脚本会创建ORDSYS 和 MDSYS 用户。 在9.2中,MDSYS 默认会被lock。

 

(2)If the ORDSYS user already existsand the MDSYS user does NOT exist:

--如果ORDSYS已经存在,而MDSYS 不存在,操作如下:

create the user MDSYS by running followingcommand:

create user MDSYS identified by<password> account lock;

grant the required privileges to MDSYS byrunning:

SQL> @?/md/admin/mdprivs.sql

 

(3)    If the ORDSYS user already exists AND the MDSYS user already existsthen you are advised to verify if the installation has been done correctly andde-install Spatial first in case of re-installation. 

--如果ORDSYS 和MDSYS 都存在,那么就需要在安装之前先卸载他们,具体的卸载不丑,参考第一部分的说明。

 

 

2.2.1.2 Install Spatial by running thefollowing procedure, as the MDSYS account should be locked you must login assys and then change the current schema:

--运行如下脚本安装Spatial:

SQL>connect / as sysdba 
SQL>alter session set current_schema=MDSYS; 
SQL>@?/md/admin/mdinst.sql

 

2.2.1.3 It is strongly recommended that theMDSYS user account remains locked. The MDSYS user is created with administratorprivileges; therefore, it is important to protect this account fromunauthorized use. 

--默认情况下MDSYS账户是locked的,这个账户有administrator 的权限,因此推荐保持lock 状态,如果解锁,使用如下命令:

 

To lock the MDSYS user, connect as SYS andenter the following command:

SQL> alter user MDSYS account lock;

 

2.2.2 Oracle 10g/11g 安装Spatial

 

2.2.2.1 准备工作

To be able to doa successful Spatial 10g / 11g installation you need to have the followingproducts already installed:

--在Oracle 10g/11g 中安装Spatial 组件,必须先保证如下三个组件已经存在:

(1)    JServer JAVA Virtual Machine

(2)    Oracle interMedia   

(3)    Oracle XML Database

 

To verify if the products are installed andvalid run:

--验证以上三个组件,可以使用如下SQL:

SQL> col comp_id for a12

SQL> col version for a15

SQL> col status for a15

SQL> select comp_id,version,status fromdba_registry where comp_id in ('JAVAVM','ORDIM','XDB');

 

COMP_ID     VERSION         STATUS

------------ ------------------------------

XDB         11.2.0.3.0      VALID

ORDIM       11.2.0.3.0      VALID

JAVAVM      11.2.0.3.0      VALID


如果没有安装或者无效,就需要解决这些组件,具体可以参考:

Oracle XDB 组件 重建 说明

http://blog.csdn.net/tianlesoftware/article/details/7323139


Oracle JAVAVM 组件 Reload 说明
http://blog.csdn.net/tianlesoftware/article/details/7334414


Where to Find the Information to Install,Upgrade, Downgrade and Deinstall interMedia/Oracle Multimedia? [ID 337415.1]

 


2.2.2.2 安装Spatial 组件

If the MDSYS user does NOT exist:

--如果MDSYS 用户不存在:

create the user MDSYS by running followingcommand:

SQL> createuser MDSYS identified by <password> default tablespace SYSAUX accountlock;

 

--赋权:

grant the required privileges to MDSYS byrunning:

   SQL> @?/md/admin/mdprivs.sql

 

If the MDSYSuser already exists then you are advised to verify if the installation has beendone correctly and de-install Spatial first in case of re-installation.

--如果用户已经存在,那么在安装之前最好先卸载, 具体卸载步骤参考第一部分。

 

   See the verification checks at the bottom of this note and a link tode-installation note.

 

Install Spatialby executing the steps shown below. Note you need to run this as a SYSDBA user!

--使用sysdaba 用户执行如下步骤:

   SQL> connect / as sysdba

   SQL> spool spatial_installation.lst

   SQL> @?/md/admin/mdinst.sql

   SQL> spool off

 

    At the end of the installation some verification steps are automaticallyexecuted!

You can also manually run the theverification steps later on.

 

It is stronglyrecommended that the MDSYS user account remains locked. The MDSYS user is createdwith administrator privileges; therefore, it is important to protect thisaccount from unauthorized use. 

 

To lock theMDSYS user, connect as SYS and enter the following command:

   SQL> alter user MDSYS account lock;

 

2.2.2.3 验证安装

 

Execute the following steps to verify ifSpatial is installed correctly:

SQL> connect/ as sysdba 
    SQL> set serveroutput on
    SQL> execute validate_sdo;
    SQL> select comp_id, control,schema, version, status, comp_name from dba_registry where comp_id='SDO';
    SQL> select object_name,object_type, status from dba_objects where owner='MDSYS' and status <>'VALID' order by object_name;

--示例:

SQL> execute validate_sdo;

PL/SQL procedure successfully completed.

 

SQL> select comp_id, control, schema,version, status, comp_name from dba_registry where comp_id='SDO';

 

COMP_ID     CONTROL      SCHEMA       VERSION         STATUS          COMP_NAME

------------ ------------ --------------------------- --------------- ---------

SDO         SYS          MDSYS        11.2.0.3.0      VALID           Spatial

 

 

 

 

-------------------------------------------------------------------------------------------------------

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Skype: tianlesoftware

Email:   tianlesoftware@gmail.com

Blog:     http://www.tianlesoftware.com

Weibo: http://weibo.com/tianlesoftware

Twitter: http://twitter.com/tianlesoftware

Facebook: http://www.facebook.com/tianlesoftware

Linkedin: http://cn.linkedin.com/in/tianlesoftware

 

 

-------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----

DBA1 群:62697716(满);   DBA2 群:62697977(满)  DBA3 群:62697850(满)  

DBA 超级群:63306533(满);  DBA4 群:83829929   DBA5群: 142216823

DBA6 群:158654907    DBA7 群:172855474   DBA总群:104207940

posted @ 2012-03-08 20:59  davedba  阅读(181)  评论(0编辑  收藏  举报