|
1 | | -/* |
2 | | - Cleanup if needed |
3 | | -*/ |
4 | | -if not exists(select * from sys.symmetric_keys where [name] = '##MS_DatabaseMasterKey##') |
5 | | -begin |
6 | | - create master key encryption by password = 'Pa$$w0rd!' |
7 | | -end |
8 | | -go |
9 | | -if exists(select * from sys.[external_data_sources] where name = 'openai_playground') |
10 | | -begin |
11 | | - drop external data source [openai_playground]; |
12 | | -end |
13 | | -go |
14 | | -if exists(select * from sys.[database_scoped_credentials] where name = 'openai_playground') |
15 | | -begin |
16 | | - drop database scoped credential [openai_playground]; |
17 | | -end |
18 | | -go |
19 | | - |
20 | | -/* |
21 | | - Create database scoped credential and external data source. |
22 | | - File is assumed to be in a path like: |
23 | | - https://<myaccount>.blob.core.windows.net/playground/wikipedia/vector_database_wikipedia_articles_embedded.csv |
24 | | -*/ |
25 | | -create database scoped credential [openai_playground] |
26 | | -with identity = 'SHARED ACCESS SIGNATURE', |
27 | | -secret = '<sas-token>'; -- make sure not to include the ? at the beginning |
28 | | -go |
29 | | -create external data source [openai_playground] |
30 | | -with |
31 | | -( |
32 | | - type = blob_storage, |
33 | | - location = 'https://<account>.blob.core.windows.net/playground', |
34 | | - credential = [openai_playground] |
35 | | -); |
36 | | -go |
37 | | - |
38 | 1 | /*
|
39 | 2 | Create table
|
40 | 3 | */
|
|
73 | 36 | Add primary key
|
74 | 37 | */
|
75 | 38 | alter table [dbo].[wikipedia_articles_embeddings]
|
76 | | -add constraint pk__wikipedia_articles_embeddings primary key nonclustered (id) |
| 39 | +add constraint pk__wikipedia_articles_embeddings primary key clustered (id) |
| 40 | +go |
| 41 | + |
| 42 | +/* |
| 43 | + Add index on title |
| 44 | +*/ |
| 45 | +create index [ix_title] on [dbo].[wikipedia_articles_embeddings](title) |
77 | 46 | go
|
78 | 47 |
|
79 | 48 | /*
|
80 | 49 | Verify data
|
81 | 50 | */
|
82 | | -select top (100) * from [dbo].[wikipedia_articles_embeddings] |
| 51 | +select top (10) * from [dbo].[wikipedia_articles_embeddings] |
83 | 52 | go
|
84 | 53 |
|
85 | 54 | select * from [dbo].[wikipedia_articles_embeddings] where title = 'Alan Turing'
|
86 | 55 | go
|
87 | 56 |
|
88 | 57 |
|
89 | 58 |
|
| 59 | + |
0 commit comments