簡體   English   中英

如何從 SQL 上的現有表在數據塊中創建表

[英]How to create a table in databricks from an existing table on SQL

有人可以讓我知道如何從 Azure sql 服務器上存在的表在 Azure Databricks 中創建表嗎? (假設 Databricks 已經與 sql 服務器建立了 jdbc 連接)。

例如,如果我的數據湖中的某個位置不存在,則以下內容將創建一個表。

CREATE TABLE IF NOT EXISTS newDB.MyTable USING delta LOCATION
'/mnt/dblake/BASE/Public/Adventureworks/delta/SalesLT.Product/'

我想做同樣的事情,但表存在於 SQL 服務器上?

這是在 Azure SQL 表上創建外部表的基本解決方案
您可以從 Azure 門戶中獲取 url(連接字符串)

create table if not exists mydb.mytable
using jdbc
options (url = 'jdbc:sqlserver://mysqlserver.database.windows.net:1433;database=mydb;user=myuser;password=mypassword;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;', dbtable = 'dbo.mytable')

檢查以下鏈接以獲取其他選項

https://spark.apache.org/docs/latest/sql-ref-syntax-ddl-create-table-datasource.htmlhttps://spark.apache.org/docs/latest/sql-data-sources-jdb .html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM