Introduction
It has been a while since I wrote my last blogpost. In the coming weeks and months I expect to invest some time in Microsoft Fabric. In the past years, I invested heavenly in Snowflake and I was and I still am enthousiastic about Snowflake. Now Microsoft has a competing product, at least according to some people and articles on the internet. And, yes, the ideas are comparable, but I also see some differences between Snowflake and Microsoft Fabric. In the coming period I'll elaborate on these differences and the things that are the same.
In this blogpost I'll discover the simple steps of creating a Synapse Data Warehouse.
The steps
After you have created Microsoft Fabric capacity and a workspace, you create a Synapse data warehouse with the following option, Show all :
Then click on the "Warehouse (Preview)" option:
And give the data warehouse a name (in my case "WH_SynapseDemo"):
And when it's finished, creating the warehouse, the following window appears. It is ready now.
And now let's try some SQL code in order to check if it works. I grabbed some where some SQL code from the very very old pubs database;-). This is the first snippet of the script:
CREATE TABLE authors(au_id idCHECK (au_id like '[0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]')CONSTRAINT UPKCL_auidind PRIMARY KEY CLUSTERED,au_lname varchar(40) NOT NULL,au_fname varchar(20) NOT NULL,phone char(12) NOT NULLDEFAULT ('UNKNOWN'),address varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,zip char(5) NULLCHECK (zip like '[0-9][0-9][0-9][0-9][0-9]'),contract bit NOT NULL)GO
DROP TABLE IF EXISTS authors;CREATE TABLE authors(au_id varchar(40) ,au_lname varchar(40) NOT NULL,au_fname varchar(20) NOT NULL,phone char(12) NOT NULL,address varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,zip char(5) NULL,contract bit NOT NULL);
DROP TABLE IF EXISTS publishers;CREATE TABLE publishers(pub_id char(4) NOT NULL,pub_name varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,country varchar(30) NULL);
CREATE TABLE titles(title_id int,title varchar(80) NOT NULL,type char(12) NOT NULLpub_id char(4) NULLREFERENCES publishers(pub_id),price money NULL,advance money NULL,royalty int NULL,ytd_sales int NULL,notes varchar(200) NULL,pubdate datetime NOT NULL)
CREATE TABLE titles(title_id int,title varchar(80) NOT NULL,type char(12) NOT NULL,pub_id char(4) NULL,price money NULL,advance money NULL,royalty int NULL,ytd_sales int NULL,notes varchar(200) NULL,pubdate datetime NOT NULL,PRIMARY KEY (title_id),FOREIGN KEY (pub_id) REFERENCES publishers(pub_id))
CREATE TABLE titles(title_id int,title varchar(80) NOT NULL,type char(12) NOT NULL,pub_id char(4) NULL,price money NULL,advance money NULL,royalty int NULL,ytd_sales int NULL,notes varchar(200) NULL,pubdate datetime NOT NULL);
DROP TABLE IF EXISTS titles;CREATE TABLE titles(title_id varchar(80),title varchar(80) NOT NULL,type char(12) NOT NULL,pub_id char(4) NULL,price DECIMAL(7,2) NULL,advance DECIMAL(7,2) NULL,royalty int NULL,ytd_sales int NULL,notes varchar(200) NULL,pubdate datetime2(0) NOT NULL);
CREATE TABLE titleauthor(au_id int,title_id int,au_ord tinyint NULL,royaltyper int NULL,);
CREATE TABLE jobs(job_id smallint IDENTITY(1,1),job_desc varchar(50) NOT NULL,min_lvl tinyint NOT NULL,max_lvl tinyint NOT NULL);
CREATE TABLE pub_info(pub_id char(4) NOT NULL,logo image NULL,pr_info text NULL);
SET NOCOUNT ONGODROP TABLE IF EXISTS authors;CREATE TABLE authors(au_id varchar(40) ,au_lname varchar(40) NOT NULL,au_fname varchar(20) NOT NULL,phone char(12) NOT NULL,address varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,zip char(5) NULL,contract bit NOT NULL);DROP TABLE IF EXISTS publishers;CREATE TABLE publishers(pub_id char(4) NOT NULL,pub_name varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,country varchar(30) NULL);DROP TABLE IF EXISTS titles;CREATE TABLE titles(title_id varchar(80),title varchar(80) NOT NULL,type char(12) NOT NULL,pub_id char(4) NULL,price DECIMAL(7,2) NULL,advance DECIMAL(7,2) NULL,royalty int NULL,ytd_sales int NULL,notes varchar(200) NULL,pubdate datetime2(0) NOT NULL);DROP TABLE IF EXISTS titleauthor;CREATE TABLE titleauthor(au_id varchar(100),title_id varchar(80),au_ord int NULL,royaltyper int NULL);DROP TABLE IF EXISTS stores;CREATE TABLE stores(stor_id char(4) NOT NULL,stor_name varchar(40) NULL,stor_address varchar(40) NULL,city varchar(20) NULL,state char(2) NULL,zip char(5) NULL);DROP TABLE IF EXISTS sales;CREATE TABLE sales(stor_id char(4) NOT NULL,ord_num varchar(20) NOT NULL,ord_date datetime2(0) NOT NULL,qty smallint NOT NULL,payterms varchar(12) NOT NULL,title_id varchar(80));DROP TABLE IF EXISTS roysched;CREATE TABLE roysched(title_id varchar(80),lorange int NULL,hirange int NULL,royalty int NULL);DROP TABLE IF EXISTS discounts;CREATE TABLE discounts(discounttype varchar(40) NOT NULL,stor_id char(4) NULL,lowqty smallint NULL,highqty smallint NULL,discount dec(4,2) NOT NULL);DROP TABLE IF EXISTS jobs;CREATE TABLE jobs(job_id smallint ,job_desc varchar(50) NOT NULL,min_lvl smallint NOT NULL,max_lvl smallint NOT NULL);DROP TABLE IF EXISTS pub_info;CREATE TABLE pub_info(pub_id char(4) NOT NULL,logo varbinary NULL,pr_info varchar(8000) NULL);DROP TABLE IF EXISTS employee;CREATE TABLE employee(emp_id varchar(40),fname varchar(20) NOT NULL,minit char(1) NULL,lname varchar(30) NOT NULL,job_id smallint NOT NULL,job_lvl smallint,pub_id char(4) NOT NULL,hire_date datetime2(0) NOT NULL)GO
Final Thoughts
- ALTER TABLE ADD/ALTER/DROP COLUMN
- BULK LOAD
- CREATE ROLE
- CREATE SECURITY POLICY - Row Level Security (RLS)
- CREATE USER
- GRANT/DENY/REVOKE
- Hints
- Identity Columns
- Manually created multi-column stats
- MASK and UNMASK (Dynamic Data Masking)
- MATERIALIZED VIEWS
- MERGE
- OPENROWSET
- PREDICT
- Queries targeting system and user tables
- Recursive queries
- Result Set Caching
- Schema and Table names can't contain / or \
- SELECT - FOR (except JSON)
- SET ROWCOUNT
- SET TRANSACTION ISOLATION LEVEL
- sp_showmemo_xml
- sp_showspaceused
- sp_rename
- Temp Tables
- Triggers
- TRUNCATE
Geen opmerkingen:
Een reactie posten