当前位置:网站首页>Bi-sql create

Bi-sql create

2022-06-25 01:15:00 Powerbi white tea

CREATE sentence

CREATE Statements in SQL Language is a very important part . Need to know SQL Grammar is basically divided into four categories : increase 、 Delete 、 Change 、 check . We usually use query statements , Although the number of other three types of grammatical statements is not very large , But it is also an indispensable part .

CREATE There are many uses of statements , Can be used to create a database , Can be used to create tables , Can be used to create views , It can also be used to create some temporary tables for calculation and use, etc .

Basic grammar

Create database :

CREATE DATABASE  Database name 

Create table :

CREATE TABLE  The name of the table 
(
 Name 1  data type ,
 Name 2  data type ,
 Name 3  data type ,
....
)

Create view :

CREATE VIEW  View name  AS
SELECT  Column (*)
FROM  The name of the table 
WHERE  filter 

Create a temporary table :

CREATE TABLE  Temporary table name  (  Column 1  data type ,  Column 2  data type ,......)
INSERT INTO  Temporary table name  ( Column 1,  Column 2,...) VALUES ( value 1,  value 2,....)
SELECT * FROM  Temporary table name 

Using examples

Case data :

In the database of white tea machine , There is a name “TEST” The database of , There is a name “ Product list ” Case data for .

Example 1:

adopt PowerBI Create a “Back_TPT” The database of .

CREATE DATABASE Backup_TPT

The result returns as follows :

It failed in the end , But we return SQL The database view is as follows :

Created successfully .

Example 2:

adopt PowerBI Create a “BAICHATEST” Table of .

CREATE TABLE BAICHATEST

give the result as follows :

Return to the database to view :

Created successfully .

Example 3:

adopt PowerBI Create a “BAICHATEST2” The view of .

CREATE VIEW BAICHATEST2 AS
SELECT *
FROM  Product list 
WHERE  Item number =01

give the result as follows :

Return to the database to view :

Created successfully .

Example 4:

adopt PowerBI Create a temporary table to query .

CREATE TABLE TEST ( BAICHA INT, ID INT)
INSERT INTO TEST
SELECT 120 AS BAICHA ,123 AS ID
SELECT * FROM TEST

give the result as follows :

Results in line with expectations .

Have a chat :

PowerBI No matter which data source is connected , All partners need to pay attention to the connection account permissions , Once the permission is too large , And if there is a read-write window , So you are in PowerBI The statements built in can all return to the corresponding database .

therefore , In addition to creating temporary virtual tables for use as queries , The other creation syntax white tea is not recommended for you .

This is white tea , One PowerBI Beginners .

原网站

版权声明
本文为[Powerbi white tea]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210542593882.html