A.1 Enabling RDF Graph Support

Before you can use any types, synonyms, or PL/SQL packages related to RDF Graph support in the current Oracle Database release, you must either install the capabilities in a new Oracle Database installation or upgrade the capabilities from a previous release.

Install of RDF Graph support is included in install of Oracle Spatial. So you must ensure that Oracle Spatial is installed. In addition, Partitioning must be enabled. Restricted use of Partitioning is allowed free of charge for supporting Graph feature of Oracle Database. See Restricted Use Licenses for more information.

A.1.1 Enabling RDF Semantic Graph Support in a New Database Installation

RDF Semantic Graph is automatically enabled when Oracle Spatial Release 12.2 or later is installed. See Manually Installing Spatial if you do not have Oracle Spatial installed by default at the time of Oracle Database installation.

If RDF Semantic Graph was enabled successfully, a row with the following column values will exist in the MDSYS.RDF_PARAMETER table:

  • NAMESPACE: MDSYS

  • ATTRIBUTE: SEM_VERSION

  • VALUE: (string starting with 12.2)

  • DESCRIPTION: VALID

A.1.2 Upgrading RDF Semantic Graph Support from Release 11.1, 11.2, or 12.1

If you are upgrading from Oracle Database Release 11.1 or 11.2 that includes the semantic technologies support, the semantic technologies support is automatically upgraded to Release 12.1 or later when the database is upgraded.

However, you may also need to migrate RDF data if you have an existing Release 11.1 or 11.2 RDF network containing triples that include typed literal values of type xsd:float, xsd:double, xsd:boolean, or xsd:time.

To check if you need to migrate RDF data, connect to the database as a user with DBA privileges and query the MDSYS.RDF_PARAMETER table, as follows:

SELECT namespace, attribute, value FROM mdsys.rdf_parameter
  WHERE namespace='MDSYS' 
  AND attribute IN ('FLOAT_DOUBLE_DECIMAL',
                    'XSD_TIME', 'XSD_BOOLEAN', 
                    'DATA_CONVERSION_CHECK');

If the FLOAT_DOUBLE_DECIMAL, XSD_TIME, or XSD_BOOLEAN attributes have the string value INVALID or if the DATA_CONVERSION_CHECK attribute has the string value FAILED_UNABLE_TO_LOCK_APPLICATION_TABLES, FAILED_INSUFFICIENT_WORKSPACE_PRIVILEGES, or FAILED_OLS_POLICIES_ARE_ENABLED, you need to migrate RDF data.

However, if the FLOAT_DOUBLE_DECIMAL, XSD_TIME, and XSD_BOOLEAN attributes do not exist or have the string value VALID and if the DATA_CONVERSION_CHECK attribute does not exist, you do not need to migrate RDF data. However, if your semantic network may have any empty RDF literals, see Handling of Empty RDF Literals; and if you choose to migrate existing empty literals to the new format, follow the steps in this section.

To migrate RDF data, follow these steps:

  1. Connect to the database as the SYSTEM (not SYS .. AS SYSDBA) user or another non-SYS user with the DBA role, and enter: SET CURRENT_SCHEMA=MDSYS

  2. Ensure that the user MDSYS has the following privileges:

    • INSERT privilege on all application tables in the semantic network

    • ALTER ANY INDEX privilege (optional: only necessary if Semantic Indexing for Documents is being used)

    • ACCESS privilege for any workspace in which version-enabled application tables have been modified (optional: only necessary if Workspace Manager is being used for RDF data)

  3. Ensure that any OLS policies for RDF data are temporarily disabled (optional: only necessary if OLS for RDF Data is being used). OLS policies can be re-enabled after running convert_old_rdf_data.

  4. Start SQL*Plus. If you want to migrate the RDF data without converting existing empty literals to the new format (see Handling of Empty RDF Literals), enter the following statement:

    EXECUTE sdo_rdf_internal.convert_old_rdf_data;
    

    If you want to migrate the RDF data and also convert existing empty literals to the new format, call convert_old_rdf_data with the flags parameter set to 'CONVERT_ORARDF_NULL'. In addition, you can use an optional tablespace_name parameter to specify the tablespace to use when creating intermediate tables during data migration. For example, the following statement migrates old semantic data, converts existing "orardf:null " values to "", and uses the MY_TBS tablespace for any intermediate tables:

    EXECUTE sdo_rdf_internal.convert_old_rdf_data(
      flags=>'CONVERT_ORARDF_NULL', 
      tablespace_name=>'MY_TBS');
    

    The sdo_rdf_internal.convert_old_rdf_data procedure may take a significant amount of time to run if the semantic network contains many triples that are using (or affected by use of) xsd:float, xsd:double, xsd:time, or xsd:boolean typed literals.

  5. Connect to the database as the SYS user with SYSDBA privileges (SYS AS SYSDBA, and enter the SYS account password when prompted). Then enter the following statement:

    • Linux: @$ORACLE_HOME/md/admin/semrelod.sql

    • Windows: @%ORACLE_HOME%\md\admin\semrelod.sql

Note:

You may encounter the ORA-00904 (invalid identifier) error when executing a SEM_MATCH query if the sdo_rdf_internal.convert_old_rdf_data procedure and the semrelod.sql script were not run after the upgrade to Release 12.1 or later.

A.1.2.1 Required Data Migration After Upgrade

After the database upgrade completes, if you have existing RDF data from a previous release, you must migrate the RDF data. If you do not perform the data migration, you will encounter the following error when running SEM_MATCH queries:

ORA-20000:  RDF_VALUE$ Table needs data migration with SEM_APIS.MIGRATE_DATA_TO_CURRENT

Columns were added to the MDSYS.RDF_VALUE$ table in Release 12.2 (see Enhanced RDF ORDER BY Query Processing). These columns must be populated after upgrading an existing RDF network. The need for migration will be noted with the following row in the MDSYS.RDF_PARAMETER table:

  • NAMESPACE: MDSYS

  • ATTRIBUTE: RDF_VALUE$

  • VALUE: INVALID_ORDER_COLUMNS

  • DESCRIPTION: RDF_VALUE$ Table needs data migration with SEM_APIS.MIGRATE_DATA_TO_CURRENT

If migration is needed, the RDF Semantic Graph installation will initially be marked as INVALD, which is signified with the following row in MDSYS.RDF_PARAMETER:

  • NAMESPACE: MDSYS

  • ATTRIBUTE: SEM_VERSION

  • VALUE: (string starting with 12.2)

  • DESCRIPTION: INVALID

To perform data migration by populating new MDSYS.RDF_VALUE$ columns, follow these steps:

  1. 1. Connect to the database as the SYSTEM (not SYS .. AS SYSDBA) user or as another non-SYS user with the DBA role.

  2. Run the following statement:

    EXECUTE sem_apis.migrate_data_to_current;

If data migration was successful, the INVALID_ORDER_COLUMNS row will be removed from MDSYS.RDF_PARAMETER and the SEM_VERSION row will have a DESCRIPTION value of VALID.

Moreover, additional data migration may be required if you are upgrading an existing Release 11.1 or 11.2 RDF network containing triples that include typed literal values of type xsd:float, xsd:double, xsd:boolean, or xsd:time.

To check if you need to perform this additional RDF data migration, connect to the database as a user with DBA privileges and query the MDSYS.RDF_PARAMETER table, as follows:

SELECT namespace, attribute, value FROM mdsys.rdf_parameter
  WHERE namespace='MDSYS' 
  AND attribute IN ('FLOAT_DOUBLE_DECIMAL',
                    'XSD_TIME', 'XSD_BOOLEAN', 
                    'DATA_CONVERSION_CHECK');

If the FLOAT_DOUBLE_DECIMAL, XSD_TIME, or XSD_BOOLEAN attributes have the string value INVALID or if the DATA_CONVERSION_CHECK attribute has the string value FAILED_UNABLE_TO_LOCK_APPLICATION_TABLES, FAILED_INSUFFICIENT_WORKSPACE_PRIVILEGES, or FAILED_OLS_POLICIES_ARE_ENABLED, you need to migrate RDF data.

However, if the FLOAT_DOUBLE_DECIMAL, XSD_TIME, and XSD_BOOLEAN attributes do not exist or have the string value VALID and if the DATA_CONVERSION_CHECK attribute does not exist, you do not need to migrate RDF data. However, if your semantic network may have any empty RDF literals, see Handling of Empty RDF Literals; and if you choose to migrate existing empty literals to the new format, follow the steps in this section.

To migrate the RDF data, follow these steps:

  1. Connect to the database as the SYSTEM (not SYS .. AS SYSDBA) user or as another non-SYS user with the DBA role , and enter: SET CURRENT_SCHEMA=MDSYS

  2. Ensure that the user MDSYS has the following privileges:

    • INSERT privilege on all application tables in the semantic network

    • ALTER ANY INDEX privilege (optional: only necessary if Semantic Indexing for Documents is being used)

    • ACCESS privilege for any workspace in which version-enabled application tables have been modified (optional: only necessary if Workspace Manager is being used for RDF data)

  3. Ensure that any OLS policies for RDF data are temporarily disabled (optional: only necessary if OLS for RDF Data is being used). OLS policies can be re-enabled after running convert_old_rdf_data.

  4. Start SQL*Plus. If you want to migrate the RDF data without converting existing empty literals to the new format (see Handling of Empty RDF Literals), enter the following statement:

    EXECUTE sdo_rdf_internal.convert_old_rdf_data;
    

    If you want to migrate the RDF data and also convert existing empty literals to the new format, call convert_old_rdf_data with the flags parameter set to 'CONVERT_ORARDF_NULL'. In addition, you can use an optional tablespace_name parameter to specify the tablespace to use when creating intermediate tables during data migration. For example, the following statement migrates old semantic data, converts existing "orardf:null " values to "", and uses the MY_TBS tablespace for any intermediate tables:

    EXECUTE sdo_rdf_internal.convert_old_rdf_data(
      flags=>'CONVERT_ORARDF_NULL', 
      tablespace_name=>'MY_TBS');
    

    The sdo_rdf_internal.convert_old_rdf_data procedure may take a significant amount of time to run if the semantic network contains many triples that are using (or affected by use of) xsd:float, xsd:double, xsd:time, or xsd:boolean typed literals.

  5. Connect to the database as the SYS user with SYSDBA privileges (SYS AS SYSDBA), and enter the SYS account password when prompted). Then enter the following statement:

    • Linux: @$ORACLE_HOME/md/admin/semrelod.sql

    • Windows: @%ORACLE_HOME%\md\admin\semrelod.sql

Note:

You may encounter the ORA-00904 (invalid identifier) error when executing a SEM_MATCH query if the sdo_rdf_internal.convert_old_rdf_data procedure and the semrelod.sql script were not run after the upgrade to Release 12.1 or later.

A.1.2.2 Handling of Empty RDF Literals

The way empty-valued RDF literals are handled was changed in Release 11.2. Before this release, the values of empty-valued literals were converted to "orardf:null". In Release 11.2 and later, such values are stored without modification (that is, as ""). However, whether you migrate existing "orardf:null" values to "" is optional.

To check if "orardf:null" values exist in your semantic network, connect to the database as a user with DBA privileges and query the MDSYS.RDF_PARAMETER table, as follows:

SELECT namespace, attribute, value FROM mdsys.rdf_parameter
  WHERE namespace='MDSYS' 
  AND attribute = 'NULL_LITERAL';

If the NULL_LITERAL attribute has the value EXISTS, then "orardf:null" values are present in your semantic network.

A.1.3 Workspace Manager and Virtual Private Database Desupport

Effective with Oracle Database Release 12.2, the following are no longer supported:

  • Workspace Manager support for RDF data

  • Virtual Private Database (VPD) support for RDF data

If an existing semantic network that contains Workspace Manager (WM) or Virtual Private Database (VPD) data is upgraded, the RDF Semantic Graph installation will be marked as INVALID. In addition, the MDSYS.RDF_PARAMETER table will contain a row with description Feature not supported in current version' for the unsupported component. To correct this situation, all existing WM and VPD data should be dropped, and the WM and VPD components should be uninstalled.

To uninstall Workspace Manager support for RDF data:

  1. Connect to the database as the SYS user with SYSDBA privileges (SYS AS SYSDBA, and enter the SYS account password when prompted).

  2. Start SQL*Plus, and enter the following statement:

    • Linux: @$ORACLE_HOME/md/admin/sdordfwm_rm.sql

    • Windows: @%ORACLE_HOME%\md\admin\sdordfwm_rm.sql

    Note:

    If you are in a multitenant environment, run the script with catcon.pl. See “Running Oracle-Supplied SQL Scripts in a CDB” in Oracle Database Administrator’s Guide.

To uninstall Virtual Private Database support for RDF data:

  1. Connect to the database as the SYSTEM user (not SYS … AS SYSDBA) or as another non-SYS user with the DBA role.

  2. Start SQL*Plus, and enter the following statement:

    EXECUTE mdsys.sem_rdfsa_dr.uninstall_vpd;

After performing the necessary uninstall operations, reset the network validity as follows:

  1. Connect to the database as the SYS user with SYSDBA privileges (SYS AS SYSDBA, and enter the SYS account password when prompted).

  2. Start SQL*Plus, and enter the following statement:

    • Linux: @$ORACLE_HOME/md/admin/semvalidate.sql

    • Windows: @%ORACLE_HOME%\md\admin\semvalidate.sql

    Note:

    If you are in a multitenant environment, run the script with catcon.pl. See “Running Oracle-Supplied SQL Scripts in a CDB” in Oracle Database Administrator’s Guide.