当前位置:网站首页>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 .

边栏推荐
- Powerbi - for you who are learning
- 天书夜读笔记——深入虚函数virtual
- QT (36) -rapidjson parsing nested JSON
- Introduction to bi-sql wildcards
- Scala IO reads by lexical units and numbers
- Which securities company should I choose to open an account online? Is it safe to open an account online?
- Deep learning LSTM model for stock analysis and prediction
- 利用 Redis 的 sorted set 做每周热评的功能
- Bi skill - judge 0 and null
- Cobalt Strike安装教程
猜你喜欢

Using macro code to generate handwriting automatically in word or WPS

4年工作經驗,多線程間的5種通信方式都說不出來,你敢信?

Text editor for QT project practice - Episode 10
The latest QQ wechat domain name anti red PHP program source code + forced jump to open

Text editor for QT project practice -- Episode 9

Add information on the left and add parts on the right of the status bar

JS Chapter 1 Summary

“一个优秀程序员可抵五个普通程序员!”

Bi-sql index

2022 melting welding and thermal cutting recurrent training question bank simulated examination platform operation
随机推荐
腾讯搬家了!
activity生命周期
Transform BeanUtils to achieve list data copy gracefully
JS Chapter 1 Summary
Lenovo tongfuyao: 11 times the general trend, we attacked the city and pulled out the stronghold all the way
This national day! Tencent cloud wecity will accompany you to travel and light up the city landmark
Scala object blending trait
Bi SQL alias
VB learning notes
最新QQ微信域名防红PHP程序源码+强制跳转打开
汇编语言(3)16位汇编基础框架与加减循环
【实用系列】家内wifi全覆盖
php easywechat 和 小程序 实现 长久订阅消息推送
中金财富证券开户佣金多少呢?股票开户交易安全靠谱吗?
联想童夫尧:11倍于大势,我们一路攻城拔寨
利用 Redis 的 sorted set 做每周热评的功能
Scala sample class
生态护航 云服务商挥起“英特尔大旗”
vb学习什么[通俗易懂]
Is it reliable to open an account on the flush with a mobile phone? Is there any hidden danger in this way