mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
@@ -19,3 +19,6 @@ Using the sample Python script in **offline** folder, you will push the necessar
|
||||
|
||||
Using the sample Python script in **private-aks** folder, you will Deploy SQL Server big data cluster in in your private network with Azure Kubernetes service (AKS) private cluster.
|
||||
|
||||
## __[OpenShift manifests and scripts](openshift/)__
|
||||
|
||||
Use manifests and scripts in **openshift** folder, to support SQL Server Big Data Clusters on OpenShift.
|
||||
+6
-3
@@ -7,7 +7,6 @@ fi
|
||||
DIR_PREFIX=$1
|
||||
|
||||
kubeadm reset --force
|
||||
unalias azdata
|
||||
|
||||
systemctl stop kubelet
|
||||
rm -rf /var/lib/cni/
|
||||
@@ -23,8 +22,12 @@ ip link set flannel.1 down
|
||||
#brctl delbr flannel.1
|
||||
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
|
||||
|
||||
rm -rf .azdata/
|
||||
rm -rf bdcdeploy/
|
||||
# Remove azdata
|
||||
#
|
||||
apt-get remove -y azdata-cli
|
||||
rm /etc/apt/sources.list.d/azdata-cli.list
|
||||
rm /etc/apt/trusted.gpg.d/dpgswdist.v1.asc.gpg
|
||||
apt autoremove
|
||||
|
||||
# Remove mounts.
|
||||
#
|
||||
|
||||
+30
-35
@@ -47,14 +47,10 @@ export VIRTUALENV_NAME="bdcvenv"
|
||||
export LOG_FILE="bdcdeploy.log"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Requirements file.
|
||||
#
|
||||
export REQUIREMENTS_LINK="https://aka.ms/azdata"
|
||||
|
||||
# Kube version.
|
||||
#
|
||||
KUBE_DPKG_VERSION=1.15.0-00
|
||||
KUBE_VERSION=1.15.0
|
||||
KUBE_DPKG_VERSION=1.16.3-00
|
||||
KUBE_VERSION=1.16.3
|
||||
|
||||
# Wait for 5 minutes for the cluster to be ready.
|
||||
#
|
||||
@@ -65,7 +61,7 @@ RETRY_INTERVAL=5
|
||||
#
|
||||
export DOCKER_REGISTRY="mcr.microsoft.com"
|
||||
export DOCKER_REPOSITORY="mssql/bdc"
|
||||
export DOCKER_TAG="2019-CU5-ubuntu-16.04"
|
||||
export DOCKER_TAG="2019-CU8-ubuntu-16.04"
|
||||
|
||||
# Variables used for azdata cluster creation.
|
||||
#
|
||||
@@ -77,7 +73,7 @@ export STORAGE_CLASS=local-storage
|
||||
export PV_COUNT="30"
|
||||
|
||||
IMAGES=(
|
||||
mssql-app-service-proxy
|
||||
mssql-app-service-proxy
|
||||
mssql-control-watchdog
|
||||
mssql-controller
|
||||
mssql-dns
|
||||
@@ -97,7 +93,7 @@ IMAGES=(
|
||||
mssql-server-controller
|
||||
mssql-server-data
|
||||
mssql-ha-operator
|
||||
mssql-ha-supervisor
|
||||
mssql-ha-supervisor
|
||||
mssql-service-proxy
|
||||
mssql-ssis-app-runtime
|
||||
)
|
||||
@@ -124,6 +120,9 @@ apt --yes install \
|
||||
software-properties-common \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
lsb-release \
|
||||
gnupg \
|
||||
wget \
|
||||
curl
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
@@ -132,31 +131,34 @@ add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
|
||||
apt update -q
|
||||
apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades
|
||||
apt-mark hold docker-ce
|
||||
apt-cache policy docker-ce
|
||||
apt --yes install docker-ce
|
||||
|
||||
usermod --append --groups docker $USER
|
||||
|
||||
# Install python3, python3-pip, requests.
|
||||
#
|
||||
apt-get install -q -y python3
|
||||
apt-get install -q -y python3-pip
|
||||
apt-get install -y libkrb5-dev
|
||||
apt-get install -y libsqlite3-dev
|
||||
apt-get install -y unixodbc-dev
|
||||
|
||||
pip3 install requests --upgrade
|
||||
|
||||
# Install and create virtualenv.
|
||||
#
|
||||
pip3 install --upgrade virtualenv
|
||||
virtualenv -p python3 $VIRTUALENV_NAME
|
||||
source $VIRTUALENV_NAME/bin/activate
|
||||
|
||||
# Install azdata cli.
|
||||
#
|
||||
pip3 install -r $REQUIREMENTS_LINK
|
||||
echo "Packages installed."
|
||||
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
|
||||
gpg --dearmor |
|
||||
tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null
|
||||
|
||||
code=$(lsb_release -cs)
|
||||
if [ $code == "focal" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
|
||||
elif [ $code == "bionic" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/prod.list)"
|
||||
elif [ $code == "xenial" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get install -y azdata-cli
|
||||
|
||||
cd -
|
||||
|
||||
azdata --version
|
||||
echo "Azdata has been successfully installed."
|
||||
|
||||
# Load all pre-requisites for Kubernetes.
|
||||
#
|
||||
@@ -351,10 +353,3 @@ kubectl config set-context --current --namespace $CLUSTER_NAME
|
||||
#
|
||||
azdata login -n $CLUSTER_NAME
|
||||
azdata bdc endpoint list --output table
|
||||
|
||||
if [ -d "$HOME/.azdata/" ]; then
|
||||
sudo chown -R $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.azdata/
|
||||
fi
|
||||
|
||||
echo "alias azdata='$BDCDEPLOY_DIR/$VIRTUALENV_NAME/bin/azdata'" >> $HOME/.bashrc
|
||||
}| tee $LOG_FILE
|
||||
|
||||
+6
-3
@@ -7,7 +7,6 @@ fi
|
||||
DIR_PREFIX=$1
|
||||
|
||||
kubeadm reset --force
|
||||
unalias azdata
|
||||
|
||||
systemctl stop kubelet
|
||||
rm -rf /var/lib/cni/
|
||||
@@ -23,8 +22,12 @@ ip link set flannel.1 down
|
||||
#brctl delbr flannel.1
|
||||
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
|
||||
|
||||
rm -rf .azdata/
|
||||
rm -rf bdcdeploy/
|
||||
# Remove azdata
|
||||
#
|
||||
apt-get remove -y azdata-cli
|
||||
rm /etc/apt/sources.list.d/azdata-cli.list
|
||||
rm /etc/apt/trusted.gpg.d/dpgswdist.v1.asc.gpg
|
||||
apt autoremove
|
||||
|
||||
# Remove mounts.
|
||||
#
|
||||
|
||||
+35
-30
@@ -30,12 +30,12 @@ export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Requirements file.
|
||||
#
|
||||
export REQUIREMENTS_LINK="https://aka.ms/azdata"
|
||||
# export REQUIREMENTS_LINK="https://aka.ms/azdata"
|
||||
|
||||
# Kube version.
|
||||
#
|
||||
KUBE_DPKG_VERSION=1.15.0-00
|
||||
KUBE_VERSION=1.15.0
|
||||
KUBE_DPKG_VERSION=1.16.3-00
|
||||
KUBE_VERSION=1.16.3
|
||||
|
||||
# Wait for 5 minutes for the cluster to be ready.
|
||||
#
|
||||
@@ -46,7 +46,7 @@ RETRY_INTERVAL=5
|
||||
#
|
||||
export DOCKER_REGISTRY="mcr.microsoft.com"
|
||||
export DOCKER_REPOSITORY="mssql/bdc"
|
||||
export DOCKER_TAG="2019-CU5-ubuntu-16.04"
|
||||
export DOCKER_TAG="2019-CU8-ubuntu-16.04"
|
||||
|
||||
# Variables used for azdata cluster creation.
|
||||
#
|
||||
@@ -58,7 +58,7 @@ export STORAGE_CLASS=local-storage
|
||||
export PV_COUNT="30"
|
||||
|
||||
IMAGES=(
|
||||
mssql-app-service-proxy
|
||||
mssql-app-service-proxy
|
||||
mssql-control-watchdog
|
||||
mssql-controller
|
||||
mssql-dns
|
||||
@@ -78,7 +78,7 @@ IMAGES=(
|
||||
mssql-server-controller
|
||||
mssql-server-data
|
||||
mssql-ha-operator
|
||||
mssql-ha-supervisor
|
||||
mssql-ha-supervisor
|
||||
mssql-service-proxy
|
||||
mssql-ssis-app-runtime
|
||||
)
|
||||
@@ -105,39 +105,51 @@ apt --yes install \
|
||||
software-properties-common \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
lsb-release \
|
||||
gnupg \
|
||||
wget \
|
||||
curl
|
||||
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
|
||||
add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
|
||||
apt update -q
|
||||
apt-get install -q --yes docker-ce=18.06.2~ce~3-0~ubuntu --allow-downgrades
|
||||
apt-mark hold docker-ce
|
||||
apt-cache policy docker-ce
|
||||
apt --yes install docker-ce
|
||||
|
||||
usermod --append --groups docker $USER
|
||||
|
||||
# Install python3, python3-pip, requests.
|
||||
#
|
||||
apt-get install -q -y python3
|
||||
apt-get install -q -y python3-pip
|
||||
apt-get install -y libkrb5-dev
|
||||
apt-get install -y libsqlite3-dev
|
||||
apt-get install -y unixodbc-dev
|
||||
apt install -y libodbc1 odbcinst odbcinst1debian2 unixodbc apt-transport-https libkrb5-dev
|
||||
|
||||
pip3 install requests --upgrade
|
||||
|
||||
# Install and create virtualenv.
|
||||
# Download and install azdata package
|
||||
#
|
||||
pip3 install --upgrade virtualenv
|
||||
virtualenv -p python3 $VIRTUALENV_NAME
|
||||
source $VIRTUALENV_NAME/bin/activate
|
||||
echo ""
|
||||
|
||||
# Install azdata cli.
|
||||
#
|
||||
pip3 install -r $REQUIREMENTS_LINK
|
||||
echo "Packages installed."
|
||||
curl -sL https://packages.microsoft.com/keys/microsoft.asc |
|
||||
gpg --dearmor |
|
||||
tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null
|
||||
|
||||
code=$(lsb_release -cs)
|
||||
if [ $code == "focal" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
|
||||
elif [ $code == "bionic" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/prod.list)"
|
||||
elif [ $code == "xenial" ]; then
|
||||
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
apt-get install -y azdata-cli
|
||||
|
||||
cd -
|
||||
|
||||
azdata --version
|
||||
echo "Azdata has been successfully installed."
|
||||
|
||||
# Load all pre-requisites for Kubernetes.
|
||||
#
|
||||
@@ -331,10 +343,3 @@ kubectl config set-context --current --namespace $CLUSTER_NAME
|
||||
#
|
||||
azdata login -n $CLUSTER_NAME
|
||||
azdata bdc endpoint list --output table
|
||||
|
||||
if [ -d "$HOME/.azdata/" ]; then
|
||||
sudo chown -R $(id -u $SUDO_USER):$(id -g $SUDO_USER) $HOME/.azdata/
|
||||
fi
|
||||
|
||||
echo "alias azdata='$BDCDEPLOY_DIR/$VIRTUALENV_NAME/bin/azdata'" >> $HOME/.bashrc
|
||||
}| tee $LOG_FILE
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
apiVersion: security.openshift.io/v1
|
||||
kind: SecurityContextConstraints
|
||||
metadata:
|
||||
annotations:
|
||||
kubernetes.io/description: SQL Server BDC custom scc is based on 'nonroot' scc plus additional capabilities.
|
||||
generation: 2
|
||||
name: bdc-scc
|
||||
allowHostDirVolumePlugin: false
|
||||
allowHostIPC: false
|
||||
allowHostNetwork: false
|
||||
allowHostPID: false
|
||||
allowHostPorts: false
|
||||
allowPrivilegeEscalation: true
|
||||
allowPrivilegedContainer: false
|
||||
allowedCapabilities:
|
||||
- SETUID
|
||||
- SETGID
|
||||
- CHOWN
|
||||
- SYS_PTRACE
|
||||
defaultAddCapabilities: null
|
||||
fsGroup:
|
||||
type: RunAsAny
|
||||
readOnlyRootFilesystem: false
|
||||
requiredDropCapabilities:
|
||||
- KILL
|
||||
- MKNOD
|
||||
runAsUser:
|
||||
type: MustRunAsNonRoot
|
||||
seLinuxContext:
|
||||
type: MustRunAs
|
||||
supplementalGroups:
|
||||
type: RunAsAny
|
||||
volumes:
|
||||
- configMap
|
||||
- downwardAPI
|
||||
- emptyDir
|
||||
- persistentVolumeClaim
|
||||
- projected
|
||||
- secret
|
||||
+1
-1
@@ -7,7 +7,7 @@ GO
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ GO
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
+12
-9
@@ -1,5 +1,5 @@
|
||||
-- ===================================================================================================================================
|
||||
-- Create database template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- Create database template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--
|
||||
-- This script will only run in the context of the master database. To manage this database in
|
||||
-- SQL Server Management Studio, either connect to the created database, or connect to master.
|
||||
@@ -9,27 +9,30 @@
|
||||
-- continuity, data protection and security, and near-zero administration — all backed by the power
|
||||
-- and reach of Microsoft Azure.
|
||||
--
|
||||
-- SQL Database is available in the following service tiers: Basic, Standard, Premium , DataWarehouse, Web (Retired)
|
||||
-- SQL Database is available in the following service tiers: GeneralPurpose, Basic, Standard, Premium , DataWarehouse, Web (Retired)
|
||||
-- and Business (Retired).
|
||||
-- General Purpose service tier is a default service tier in Azure SQL Database that is designed for most of the generic workloads.
|
||||
-- If you need a fully managed database engine with 99.99% SLA with storage latency between 5 and 10 ms that match Azure SQL
|
||||
-- IaaS in most of the cases, General Purpose tier is the option for you.
|
||||
-- Standard is the go-to option for getting started with cloud-designed business applications and
|
||||
-- offers mid-level performance and business continuity features. Performance objectives for Standard
|
||||
-- deliver predictable per minute transaction rates.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/p/?LinkId=306622 for more information about Azure SQL Database.
|
||||
-- See https://go.microsoft.com/fwlink/p/?LinkId=306622 for more information about Azure SQL Database.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/?LinkId=787140 for more information about Azure SQL Data Warehouse.
|
||||
-- See https://go.microsoft.com/fwlink/?LinkId=787140 for more information about Azure Synapse Analytics.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/p/?LinkId=402063 for more information about CREATE DATABASE for Azure SQL Database.
|
||||
-- See https://go.microsoft.com/fwlink/p/?LinkId=402063 for more information about CREATE DATABASE for Azure SQL Database.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/?LinkId=787139 for more information about CREATE DATABASE for Azure SQL Data Warehouse Database.
|
||||
-- See https://go.microsoft.com/fwlink/?LinkId=787139 for more information about CREATE DATABASE for Azure Synapse Analytics Database.
|
||||
-- ===================================================================================================================================
|
||||
|
||||
|
||||
CREATE DATABASE <Database_Name, sysname, Database_Name> COLLATE <collation_Name, sysname, SQL_Latin1_General_CP1_CI_AS>
|
||||
(
|
||||
EDITION = '<EDITION, , Standard>',
|
||||
SERVICE_OBJECTIVE='<SERVICE_OBJECTIVE,,S0>',
|
||||
MAXSIZE = <MAX_SIZE,,250 GB>
|
||||
EDITION = '<EDITION, , GeneralPurpose>',
|
||||
SERVICE_OBJECTIVE='<SERVICE_OBJECTIVE,,GP_Gen5_2>',
|
||||
MAXSIZE = <MAX_SIZE,,32 GB>
|
||||
)
|
||||
|
||||
GO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- ===================================================================================
|
||||
-- Drop database template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===================================================================================
|
||||
-- ===================================================================================================================================
|
||||
-- Drop database template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand Database
|
||||
-- ===================================================================================================================================
|
||||
DROP DATABASE <Database_Name, sysname, Database_Name>
|
||||
GO
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =========================================================================
|
||||
-- Alter external data source template for Azure SQL Data Warehouse Database
|
||||
-- =========================================================================
|
||||
-- ========================================================================
|
||||
-- Alter external data source template for Azure Synapse Analytics Database
|
||||
-- ========================================================================
|
||||
|
||||
ALTER EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source> SET
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
-- ==========================================================================
|
||||
-- Create external data source template for Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================
|
||||
-- =========================================================================
|
||||
-- Create external data source template for Azure Synapse Analytics Database
|
||||
-- =========================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
CREATE EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source> WITH
|
||||
(
|
||||
TYPE = <data_source_type, sysname, sample_type>,
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
RESOURCE_MANAGER_LOCATION = N'<resource_manager_location, sysname, sample_resource_manager_location>',
|
||||
CREDENTIAL = <credential_name, sysname, sample_credential>
|
||||
TYPE = <data_source_type, sysname, sample_type>,
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
RESOURCE_MANAGER_LOCATION = N'<resource_manager_location, sysname, sample_resource_manager_location>',
|
||||
CREDENTIAL = <credential_name, sysname, sample_credential>
|
||||
)
|
||||
GO
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
-- ===============================================================================================
|
||||
-- Drop external data source template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===============================================================================================
|
||||
-- ======================================================================================================================================
|
||||
-- Drop external data source template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ======================================================================================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ==========================================================================
|
||||
-- Create external file format template for Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================
|
||||
-- =========================================================================
|
||||
-- Create external file format template for Azure Synapse Analytics Database
|
||||
-- =========================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================
|
||||
-- Drop external file format template for Azure SQL Data Warehouse Database
|
||||
-- ========================================================================
|
||||
-- ==================================================================================================================
|
||||
-- Drop external file format template for Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ==================================================================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =====================================================================
|
||||
-- Create Scalar Function Template for Azure SQL Data Warehouse Database
|
||||
-- =====================================================================
|
||||
-- ====================================================================
|
||||
-- Create Scalar Function Template for Azure Synapse Analytics Database
|
||||
-- ====================================================================
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--===================================================================================
|
||||
-- Drop function template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--====================================================================================
|
||||
--==================================================================================
|
||||
-- Drop function template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--===================================================================================
|
||||
IF OBJECT_ID (N'<schema_name, sysname, dbo>.<function_name, sysname, EmployeeByID>') IS NOT NULL
|
||||
DROP FUNCTION <schema_name, sysname, dbo>.<function_name, sysname, EmployeeByID>
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ==================================================================================
|
||||
-- Create index template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ==================================================================================
|
||||
-- =================================================================================
|
||||
-- Create index template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =================================================================================
|
||||
|
||||
CREATE INDEX <index_name, sysname, ind_test>
|
||||
ON <schema_name, sysname, Person>.<table_name, sysname, Address>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--========================================================================
|
||||
-- Drop index template for Azure SQL Database and Azure SQL Data Warehouse
|
||||
--========================================================================
|
||||
--=======================================================================
|
||||
-- Drop index template for Azure SQL Database and Azure Synapse Analytics
|
||||
--=======================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.indexes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ======================================================================================
|
||||
-- Create SQL Login template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ======================================================================================
|
||||
-- =============================================================================================================================
|
||||
-- Create SQL Login template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- =============================================================================================================================
|
||||
|
||||
CREATE LOGIN <SQL_login_name, sysname, login_name>
|
||||
WITH PASSWORD = '<password, sysname, Change_Password>'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ====================================================================================
|
||||
-- Drop SQL Login template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ====================================================================================
|
||||
-- ===========================================================================================================================
|
||||
-- Drop SQL Login template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===========================================================================================================================
|
||||
|
||||
DROP LOGIN <login_name, sysname, login_name>
|
||||
Go
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ==========================================================================================
|
||||
-- Create Database Role template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================================
|
||||
-- =========================================================================================
|
||||
-- Create Database Role template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =========================================================================================
|
||||
-- Create the database role
|
||||
CREATE ROLE <role_name, sysname, Production_Owner> AUTHORIZATION [dbo]
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================================
|
||||
-- Drop Database Role template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- ===============================================================================================================================
|
||||
-- Drop Database Role template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===============================================================================================================================
|
||||
|
||||
-- Drop the role
|
||||
DROP ROLE <role_name, sysname, Production_Owner>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ===================================================================================
|
||||
-- Create Schema Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===================================================================================
|
||||
-- ==========================================================================================================================
|
||||
-- Create Schema Template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ==========================================================================================================================
|
||||
|
||||
CREATE SCHEMA <sample_schema, sysname, sample_schema>
|
||||
AUTHORIZATION <owner_name, sysname, owner_name>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--==================================================================================
|
||||
-- Drop Schema template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--==================================================================================
|
||||
--=========================================================================================================================
|
||||
-- Drop Schema template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=========================================================================================================================
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM sys.schemas
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===============================================================================================
|
||||
-- Create Sampled Statistics Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===============================================================================================
|
||||
-- ======================================================================================================================================
|
||||
-- Create Sampled Statistics Template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ======================================================================================================================================
|
||||
CREATE STATISTICS <statistics_name, sysname, statistics_name>
|
||||
ON <schema_name, sysname, schema_name>.<table_name, sysname, table_name>
|
||||
(
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
--======================================================================================
|
||||
-- Drop Statistics template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--======================================================================================
|
||||
--=============================================================================================================================
|
||||
-- Drop Statistics template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=============================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.stats as st
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ======================================================================
|
||||
-- Create Stored Procedure Template for Azure SQL Data Warehouse Database
|
||||
-- ======================================================================
|
||||
-- =====================================================================
|
||||
-- Create Stored Procedure Template for Azure Synapse Analytics Database
|
||||
-- =====================================================================
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===========================================================================================
|
||||
-- Drop Stored Procedure Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===========================================================================================
|
||||
-- ==========================================================================================
|
||||
-- Drop Stored Procedure Template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- ==========================================================================================
|
||||
|
||||
-- Drop stored procedure if it already exists
|
||||
IF EXISTS (
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ====================================================================
|
||||
-- Create External Table Template for Azure SQL Data Warehouse Database
|
||||
-- ====================================================================
|
||||
-- ===================================================================
|
||||
-- Create External Table Template for Azure Synapse Analytics Database
|
||||
-- ===================================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_external_table>', 'U') IS NOT NULL
|
||||
DROP EXTERNAL TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_external_table>
|
||||
|
||||
+13
-5
@@ -1,24 +1,32 @@
|
||||
-- =========================================
|
||||
-- Create Graph Edge Template
|
||||
-- Create Graph Edge Table Template
|
||||
-- =========================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
DROP TABLE IF EXISTS <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
GO
|
||||
|
||||
CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
(
|
||||
-- Columns are optional for Edge Tables.
|
||||
-- Columns are optional for Graph Edge Tables.
|
||||
--
|
||||
<column1_name, sysname, c1> <column1_datatype, , int> <column1_nullability, , NOT NULL>,
|
||||
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability, , NULL>,
|
||||
<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability, , NULL>,
|
||||
|
||||
-- System generated edge constraint.
|
||||
--
|
||||
CONNECTION (<node_table_name TO <node_table_name>),
|
||||
|
||||
CONSTRAINT EC_<constraint_name> CONNECTION (<node_table_name TO <node_table_name>, <node_table_name> TO <node_table_name>),
|
||||
-- Unique index on $edge_id is required.
|
||||
-- If no user-defined index is specified, a default index is created instead.
|
||||
-- If no user-defined index is specified, a default index is created.
|
||||
--
|
||||
INDEX ix_graphid UNIQUE ($edge_id),
|
||||
|
||||
-- indexes on $from_id and $to_id are optional, but support faster lookups.
|
||||
--
|
||||
INDEX ix_fromid ($from_id, $to_id),
|
||||
INDEX ix_toid ($to_id, $from_id)
|
||||
)
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =======================================================================
|
||||
-- Create Partitioned Table Template for Azure SQL Data Warehouse Database
|
||||
-- =======================================================================
|
||||
-- ======================================================================
|
||||
-- Create Partitioned Table Template for Azure Synapse Analytics Database
|
||||
-- ======================================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===========================================================
|
||||
-- Create Table Template for Azure SQL Data Warehouse Database
|
||||
-- ===========================================================
|
||||
-- ==========================================================
|
||||
-- Create Table Template for Azure Synapse Analytics Database
|
||||
-- ==========================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
BEGIN
|
||||
--If table is system-versioned, SYSTEM_VERSIONING must be set to OFF first
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<temporal_table_name, sysname, sample_table>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
--==========================================================================================
|
||||
-- Drop External Table template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--==========================================================================================
|
||||
--=================================================================================================================================
|
||||
-- Drop External Table template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=================================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.tables
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--=================================================================================
|
||||
-- Drop Table template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--=================================================================================
|
||||
--================================================================================
|
||||
-- Drop Table template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.tables
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- =======================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =======================================================================================
|
||||
-- For login <login_name, sysname, login_name>, create a user in the database
|
||||
CREATE USER <user_name, sysname, user_name>
|
||||
FOR LOGIN <login_name, sysname, login_name>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- ========================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- ===============================================================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===============================================================================================================================
|
||||
DROP USER <user_name, sysname, user_name>
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- =================================================================================
|
||||
-- Create View template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- =================================================================================
|
||||
-- ================================================================================
|
||||
-- Create View template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- ================================================================================
|
||||
|
||||
IF object_id(N'<schema_name, sysname, dbo>.<view_name, sysname, Top10Sales>', 'V') IS NOT NULL
|
||||
DROP VIEW <schema_name, sysname, dbo>.<view_name, sysname, Top10Sales>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--================================================================================
|
||||
-- Drop View template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--================================================================================
|
||||
--=======================================================================================================================
|
||||
-- Drop View template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=======================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.views
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
-- =========================================
|
||||
-- Create Graph Edge Template
|
||||
-- Create Graph Edge Table Template
|
||||
-- =========================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
DROP TABLE IF EXISTS <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
GO
|
||||
|
||||
CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
(
|
||||
-- Columns are optional for Edge Tables.
|
||||
-- Columns are optional for Graph Edge Tables.
|
||||
--
|
||||
<column1_name, sysname, c1> <column1_datatype, , int> <column1_nullability, , NOT NULL>,
|
||||
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability, , NULL>,
|
||||
<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability, , NULL>,
|
||||
|
||||
-- System generated edge constraint.
|
||||
--
|
||||
CONNECTION (<node_table_name TO <node_table_name>),
|
||||
|
||||
CONSTRAINT EC_<constraint_name> CONNECTION (<node_table_name TO <node_table_name>, <node_table_name> TO <node_table_name>),
|
||||
-- Unique index on $edge_id is required.
|
||||
-- If no user-defined index is specified, a default index is created.
|
||||
--
|
||||
INDEX ix_graphid UNIQUE ($edge_id),
|
||||
|
||||
-- indexes on $from_id and $to_id are optional, but support faster lookups.
|
||||
--
|
||||
INDEX ix_fromid ($from_id, $to_id),
|
||||
INDEX ix_toid ($to_id, $from_id)
|
||||
)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
BEGIN
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_memoryoptimizedtable>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_memoryoptimizedtable>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<table_name, sysname, sample_memoryoptimizedtable>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
@@ -16,7 +16,7 @@ GO
|
||||
|
||||
BEGIN
|
||||
--If table is system-versioned, SYSTEM_VERSIONING must be set to OFF first
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<temporal_table_name, sysname, sample_table>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
--
|
||||
-- This template creates a table with a CHECK CONSTRAINT,
|
||||
-- then it removes the CHECK CONSTRAINT from the table
|
||||
|
||||
-- Note: The DROP syntax can also be used to drop
|
||||
-- Edge Constraint object types. To achieve this replace
|
||||
-- the constraint_name attribute with the name of the
|
||||
-- respective Edge Constraint object
|
||||
-- ========================================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
Reference in New Issue
Block a user