Configure PolyBase to access external data in Oracle
The article explains how to use PolyBase on a SQL Server instance to query external data in Oracle.
If you haven't installed PolyBase, see PolyBase installation.
Before creating a database scoped credential, a Master Key must be created.
Configure an Oracle external data source
To query the data from an Oracle data source, you must create external tables to reference the external data. This section provides sample code to create these external tables.
The following Transact-SQL commands are used in this section:
- CREATE DATABASE SCOPED CREDENTIAL (Transact-SQL)
- CREATE EXTERNAL DATA SOURCE (Transact-SQL)
- CREATE STATISTICS (Transact-SQL)
Create a database scoped credential for accessing the Oracle source.
/* specify credentials to external data source * IDENTITY: user name for external source. * SECRET: password for external source. */ CREATE DATABASE SCOPED CREDENTIAL credential_name WITH IDENTITY = 'username', Secret = 'password';
Create an external data source with CREATE EXTERNAL DATA SOURCE.
/* * LOCATION: Location string should be of format '<vendor>://<server>[:<port>]'. * PUSHDOWN: specify whether computation should be pushed down to the source. ON by default. * CONNECTION_OPTIONS: Specify driver location * CREDENTIAL: the database scoped credential, created above. */ CREATE EXTERNAL DATA SOURCE external_data_source_name WITH ( LOCATION = 'oracle://<server address>[:<port>]', -- PUSHDOWN = ON | OFF, CREDENTIAL = credential_name)
Optional: Create statistics on an external table.
We recommend creating statistics on external table columns especially the ones used for joins, filters and aggregates,for optimal query performance.
CREATE STATISTICS statistics_name ON customer (C_CUSTKEY) WITH FULLSCAN;
Once you have created an external data source, you can use the CREATE EXTERNAL TABLE command to create a queryable table over that source.
For more information and examples, see the following articles: