Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 975c52b

Browse files
committed
Merge branch 'patch-5' of https://github.com/pabechevb/sql-docs into 20211129-external-table
2 parents f95f64f + 3b6e054 commit 975c52b

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

docs/relational-databases/polybase/polybase-configure-mongodb.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ To query the data from a MongoDB data source, you must create external tables to
3131
The following Transact-SQL commands are used in this section:
3232

3333
- [CREATE DATABASE SCOPED CREDENTIAL (Transact-SQL)](../../t-sql/statements/create-database-scoped-credential-transact-sql.md)
34-
- [CREATE EXTERNAL DATA SOURCE (Transact-SQL)](../../t-sql/statements/create-external-data-source-transact-sql.md)
34+
- [CREATE EXTERNAL DATA SOURCE (Transact-SQL)](../../t-sql/statements/create-external-data-source-transact-sql.md)
35+
- [CREATE EXTERNAL TABLE (Transact-SQL)](../../t-sql/statements/create-external-table-transact-sql.md)
3536
- [CREATE STATISTICS (Transact-SQL)](../../t-sql/statements/create-statistics-transact-sql.md)
3637

3738
1. Create a database scoped credential for accessing the MongoDB source.
@@ -66,6 +67,24 @@ The following Transact-SQL commands are used in this section:
6667
[ ; ]
6768
```
6869

70+
1. Create an external table.
71+
72+
The following script creates te external table. For reference, see [CREATE EXTERNAL TABLE](../../t-sql/statements/create-external-table-transact-sql.md). Before you run the script update it for your environment:
73+
74+
- Update the fields with their name, collation, and if they are collections then specify the colection name and the field name, note "friends" is a custom data type.
75+
- Update the location. Set the database name and the table name. Note three-part names are not allowed, so you can't create it for the system.profile table. Also you can't specify a view because it can't obtain the metadata from it.
76+
- Update the data source with the name of the one you created in the previous step.
77+
78+
```sql
79+
CREATE EXTERNAL TABLE [MongoDbRandomData](
80+
[_id] NVARCHAR(24) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
81+
[RandomData_friends_id] INT,
82+
[RandomData_tags] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CI_AS)
83+
WITH (
84+
LOCATION='MyDb.RandomData',
85+
DATA_SOURCE=[MongoDb])
86+
```
87+
6988
1. **Optional:** Create statistics on an external table.
7089
7190
We recommend creating statistics on external table columns, especially the ones used for joins, filters and aggregates, for optimal query performance.

0 commit comments

Comments
 (0)