当前位置:网站首页>Bi SQL drop & alter
Bi SQL drop & alter
2022-06-23 09:50: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 .
边栏推荐
- What is a closure function
- Simple understanding of quick sort
- [GYCTF2020]Blacklist
- [SUCTF 2019]CheckIn
- UEFI源码学习3.7 - NorFlashDxe
- Go string comparison
- Redis learning notes RDB of persistence mechanism
- Navagation navigation
- [CISCN2019 华北赛区 Day2 Web1]Hack World
- I have been promoted. How can I get along with my former colleagues at the same level?
猜你喜欢

UEFI source code learning 4.1 - pcihostbridgedxe

使用base64,展示图片

Alimentation des animaux de compagnie basée sur stm32

Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award

Set the CPU to have 16 address lines and 8 data lines, and use mreq as the access control line number Connection between memory and CPU

AI system frontier dynamics issue 38: Google has abandoned tensorflow?; Four GPU parallel strategies for training large models; Father of llvm: modular design determines AI future
![[极客大挑战 2019]HardSQL](/img/73/ebfb410296b8e950c9ac0cf00adc17.png)
[极客大挑战 2019]HardSQL
Redis learning notes - AOF of persistence mechanism

ICLR 2022 | dynamic convolution tadaconv in video and efficient convolution video understanding model tadaconvnext

Wechat applet: click the button to switch frequently, overlap the custom markers, but the value does not change
随机推荐
ICLR 2022 | 视频中的动态卷积TAdaConv以及高效的卷积视频理解模型TAdaConvNeXt
What is a closure function
Mysql database introduction summary
UEFI source code learning 4.1 - pcihostbridgedxe
UCOSII (learning notes)
Common English explanations in arm
【CTF】bjdctf_2020_babyrop
必须知道的RPC内核细节(值得收藏)!!!
RBtree
UEFI源码学习3.7 - NorFlashDxe
High performance computing center RDMA implementation technology
Sequential representation and implementation of sequencelist -- linear structure
分布式常见面试题
Centre de calcul haute performance - nvme / nvme - of - nvme - of overview
谷贱伤农,薪贱伤码农!
[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist
[geek challenge 2019] hardsql
Redis learning notes - publish and subscribe
开发者,你对云计算可能有些误解
Web -- Information Disclosure