当前位置:网站首页>Bi SQL drop & alter
Bi SQL drop & alter
2022-06-25 01:15:00 【Powerbi white tea】

Drop & Alter
Drop, Cancel the operation ;Alter, update operation .
stay PowerBI in , If we modify some data cleaning operations , Just open the advanced editor to view M Language , You can modify and delete specific statements .
But in the database warehouse , We often need the help of Drop and Alter Or other statements to modify the data warehouse .
Why can't we be in a data warehouse like PowerQuery Do the same in ?
In fact, this is related to the positioning of the two .
PowerQuery The positioning of , Is aimed at PowerView To serve , although PowerQuery Self system , It can be called a mini data warehouse , But in general , The data we get from the standard data warehouse are relatively clean data .
SQL Servers The positioning of , It is one of the international basic database languages , Its positioning is a large data warehouse . In the standardized standards of data governance , The data warehouse must be stable 、 Continuously provide data source .
therefore , For the sake of database stability , If we need to modify and adjust the logic of the data warehouse , There must be a set of standardized operation processes and specialized logic modification statements .
grammar
Drop grammar :
1. Delete index :
DROP INDEX The index name ON The name of the table
2. Delete table :
DROP TABLE The name of the table
notes : This operation , Will delete the structure of the table 、 Properties and index !
3. Delete database :
DROP DATABASE Database name
4. Keep the table structure , Delete data only :
TRUNCATE TABLE The name of the table
Alter grammar :
1. Add columns to the table :
ALTER TABLE The name of the table
ADD Column name data type
2. Delete the column in the table :
ALTER TABLE The name of the table
DROP COLUMN Column name
3. Change the data type of the column in the table :
ALTER TABLE The name of the table
ALTER COLUMN Column name data type
Constraints Add
White tea has shared several types of constraints before , In fact, there were additional Drop and Alter Operation of the , Considering the classification problem , White tea decided to put it in this issue .
All the following syntax , When the table has been created , We need to make changes to the constraints .
- UNIQUE( only ) to update : Add unique constraint :
ALTER TABLE The name of the table
ADD UNIQUE ( Column name )
Add multiple column unique constraints :
ALTER TABLE The name of the table
ADD CONSTRAINT uc_ Constraint name UNIQUE ( Column name , Column name ...)
Undo unique constraint :
ALTER TABLE The name of the table
DROP CONSTRAINT uc_ Constraint name
- PRIMARY KEY( Primary key ) to update :
Add a primary key constraint :
ALTER TABLE The name of the table
ADD PRIMARY KEY ( Column name )
Add multiple column primary key constraints :
ALTER TABLE The name of the table
ADD CONSTRAINT pk_ Constraint name PRIMARY KEY ( Column name , Column name ...)
Undo the primary key constraint :
ALTER TABLE The name of the table
DROP CONSTRAINT pk_ Constraint name
- FOREIGN KEY( Foreign keys ) to update :
New foreign key constraint :
ALTER TABLE The name of the table
ADD FOREIGN KEY ( Column name )
REFERENCES Primary key table ( Column name )
Add multiple column foreign key constraints :
ALTER TABLE The name of the table
ADD CONSTRAINT fk_ Constraint name
FOREIGN KEY ( Column name )
REFERENCES Primary key table ( Column name )
Undo the foreign key constraint :
ALTER TABLE The name of the table
DROP CONSTRAINT fk_ Constraint name
- CHECK( Check ) to update :
Add check constraint :
ALTER TABLE The name of the table
ADD CHECK ( Column name Comparison symbol " Conditions ")
Add multi column check constraint :
ALTER TABLE The name of the table
ADD CONSTRAINT chk_ Constraint name CHECK ( Column name Comparison symbol " Conditions " AND Column name Comparison symbol " Conditions " ......)
Undo check constraint :
ALTER TABLE The name of the table
DROP CONSTRAINT chk_ Constraint name
- DEFAULT( The default value is ) to update :
New default value constraint :
ALTER TABLE The name of the table
ALTER COLUMN Column name SET DEFAULT ' The default value is '
Undo the default value constraint :
ALTER TABLE The name of the table
ALTER COLUMN Column name DROP DEFAULT

That's the end of this issue , No use cases , Because we do BI In fact, it is rare for the front end to use such operations , We are more simply using query aggregation statements .
Of course , Yes ETL And interested partners of the data warehouse can have a try .


This is white tea , One PowerBI Beginners .

边栏推荐
- Cloud development technology summit · public welfare programming challenge [hot registration]!
- 51单片机多机通信
- 扎克伯格上手演示四款VR头显原型机,Meta透露元宇宙「家底」
- 智能合约安全审计入门篇 —— delegatecall (2)
- Text editor of QT project practice ---------- episode 11
- Golang example renewal lock: redis+channel+sync Mutex
- 云开发技术峰会·公益编程挑战赛【火热报名中】!
- Text editor of QT project practice ---------- episode 8
- Start service 11111
- 对技术的乐观,正让戴尔取得比想象中更多的成就
猜你喜欢

汇编语言(4)函数传参

Powerbi - for you who are learning

Bi-sql Union

Rich text tables, lists, pictures

Bi skill - judge 0 and null

Text editor for QT project practice - Episode 10

Scala IO read by line

Deep learning LSTM model for stock analysis and prediction

Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source! (high performance + high customization)

QT electronic clock
随机推荐
Text editor of QT project practice ---------- episode 11
Sanic service startup failed
If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
云开发技术峰会·公益编程挑战赛【火热报名中】!
Text editor of QT project practice ---------- episode 8
QT electronic clock
Bi-sql - different join
Using bindservice method to pause music playing
ImageView展示网络图片
C语言边界计算和不对称边界
Zuckerberg demonstrated four VR head display prototypes, and meta revealed the "family" of metauniverse
4年工作經驗,多線程間的5種通信方式都說不出來,你敢信?
matlab 取整
Scala trait construction mechanism
Tencent has completed the comprehensive cloud launch to build the largest cloud native practice in China
Cobalt strike installation tutorial
4 ans d'expérience de travail, 5 modes de communication Multi - thread ne peuvent pas être décrits, vous osez croire?
2022 simulated 100 questions of safety officer-c certificate examination and online simulated examination
Tencent cloud wecity Hello 2022!
Distinguish between i++ and ++i seconds