选择sql查询语句大全文库(SQL query Daquan Library)

sql查询语句大全  时间:2021-02-27  阅读:()

sql查询语句大全文库SQL query Daquan LibrarySQL query Daquan.Txt library to stay up late, because thecourage to end the day; stay in bed because of the courage tostart the day. Friend is who can see you and love you. SQL querystatement Daquan

Statement function

1, data manipulation

Select -- retrieving rows and columns from a database tableInsert -- adding new data rows to a database table

Delete -- deleting data rows from database tables

Update -- update the data in the database table

2, data definition

Create TABLE -- create a database table

Drop TABLE -- delete tables from the database

Alter TABLE -- modifying the structure of the database tableCreate VIEW - create a view

Drop VIEW -- delete views from the database

Create INDEX -- create an index for the database table

Drop INDEX -- delete index from database

Create PROCEDURE - creating a stored procedure

Drop PROCEDURE -- delete stored procedures from the databaseCreate TRIGGER - creating a trigger

Drop TRIGGER -- delete triggers from the database

Create SCHEMA -- add a new schema to the database

Drop SCHEMA - deletes a schema from the database

Create DOMAIN -- creating a data range

Alter DOMAIN - change domain definition

Drop DOMAIN -- deletes a domain from the database

3, data control

GRANT -- grant user access rights

DENY -- deny user access

REVOKE -- removing user access rights

4, transaction control

COMMIT - end the current transaction

ROLLBACK -- abort the current transaction

SET TRANSACTION -- defining the access characteristics ofcurrent transaction data

5, programmed SQL

DECLARE -- setting cursors for queries

EXPLAN -- description of data access plan for queriesOPEN - retrieve the query results and open a cursorFETCH -- retrieve a row of query results

CLOSE - close the cursor

PREPARE -- preparing SQL statements for dynamic executionEXECUTE -- dynamic execution of SQL statements

DESCRIBE - describe the prepared query

6, local variables

Declare @id char (10)

--set @id =' 10010001'

Select @id =' 10010001'

7, global variables

- must be at the beginning of @ @8, IF statement

Declare @x int @y int @z int

Select @x = 1 @y = 2 @z=3

If @x > @y

Print'x > Y'- print string'x > Y'Else if @y > @z

Print'y > z'

Else print'z > Y'

9, CASE statement

Use Pangu

Update employee

Set e_wage =

Case

When job_level = ' 1' then e_wage*1.08

When job_level = '2' then e_wage*1.07

When job_level = '3' then e_wage*1.06

Else e_wage*1.05

End

10, WHILE CONTINUE BREAK statement

Declare @x int @y int @c int

Select @x = 1 @y=1

While @x < 3

Begin

Print @x -- the value of the print variable xWhile @y < 3

Begin

Select @c =100*@x+ @y

Print @c -- the value of the print variable C

Select @y = @y + 1

End

Select @x = @x + 1

Select @y = 1

End

11, WAITFOR statement

The example waits for 1 hours, 2 minutes, 3 seconds to executethe Select statement

Waitfor delay '01:02:03'

从雇员中选择*

——例等到晚上11点零8分后才执行选择语句

等待时间的23:08:00”

从雇员中选择*

12、选择语句

选择* 列名从table_name 表名在col umn_name算子值例 宿主

SELECT * FROM stock_information哪里StockID中= str NIDs tockname = “str_name”

s tockname像“%发现这%stockname如[A-Za-z] % ---------  [ ]指定值的范围s tockname喜欢[ ^调频] % --------- ^排除指定范围

---------只能在使用像关键字的哪里子句中使用通配符

或stockpath = “stock_path”

或sto cknumb er1000

和股票指数= 24

不stocksex = '人's tocknumber之间的20和100

在sto cknumb er 10、 20、 30

通过StockID中倒序ASC ---------排序 desc -降序 ASC升序由1,2 ---------通过列号秩序stockname = 选择从哪里stockname stock_information StockID中= 4

---------子查询

---------除非能确保内层选择只返回一个行的值

---------否则应在外层哪里子句中用一个在限定符

选择不同的c o lumn_name形式tab l e_name ---------不同指定检索独有的列值不重复

选择s tocknumber “s tocknumber + 10 + 10 = sto cknumb er从t ab l e_n ame

选择stockname “stocknumber” =数*从table_name组s tockname---------组将表按行分组指定列中有相同的值

具有计数* = 2 ---------具有选定指定的组

选择*

从表1表2

在table1. id * = tabl e2. id --------左外部连接表1中有的而表中没有得以空表示table1. id = * table2. id --------右外部连接

选择s tockname从表1

联盟[全部] -----联盟合并查询结果集全保留重复行

选择s tockname从表2

13、插入语句

插入tab l e_names toc k_names toc k_numb er值 “XXX” 、 “XXXX” 值选择stockname s tocknumber从stock_tabl e2 ---价值为选择语句

14、更新语句

更新tabl e_name集stockname = “XXX” [ 3 ]在Stock ID中=s tockname =默认stockname = nulls tocknumber = st ockname + 4

15、删除语句

删除从table_name哪里StockID中= 3

截断t ab l e_n ame -----------删除表中所有行仍保持表的完整性表t ab l e_nam e---------------完全删除表

16、 ALTER TABLE *** ---修改数据库表结构

修改表database.owner.table_name添加column_name char 2空. . . . .

华圣云 HuaSaint-阿里云国际站一级分销商,只需一个邮箱即可注册国际账号,可代充值

简介华圣云 HuaSaint是阿里云国际版一级分销商(诚招募二级代理),专业为全球企业客户与个人开发者提供阿里云国际版开户注册、认证、充值等服务,通过HuaSaint开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡,不需要买海外电话卡,绝对的零门槛,零风险官方网站:www.huasaint.com企业名:huaSaint Tech Limited阿里云国际版都有什么优势?阿里云国际版的产品...

极光KVM美国美国洛杉矶元/极光kvmCN7月促销,美国CN2 GIA大带宽vps,洛杉矶联通CUVIP,14元/月起

极光KVM怎么样?极光KVM本月主打产品:美西CN2双向,1H1G100M,189/年!在美西CN2资源“一兆难求”的大环境下,CN2+大带宽 是很多用户的福音,也是商家实力的象征。目前,极光KVM在7月份的促销,7月促销,美国CN2 GIA大带宽vps,洛杉矶联通cuvip,14元/月起;香港CN2+BGP仅19元/月起,这次补货,机会,不要错过了。点击进入:极光KVM官方网站地址极光KVM七月...

福州云服务器 1核 2G 2M 12元/月(买5个月) 萤光云

厦门靠谱云股份有限公司 双十一到了,站长我就给介绍一家折扣力度名列前茅的云厂商——萤光云。1H2G2M的高防50G云服务器,依照他们的规则叠加优惠,可以做到12元/月。更大配置和带宽的价格,也在一般云厂商中脱颖而出,性价比超高。官网:www.lightnode.cn叠加优惠:全区季付55折+满100-50各个配置价格表:地域配置双十一优惠价说明福州(带50G防御)/上海/北京1H2G2M12元/月...

sql查询语句大全为你推荐
万维读者网《读者》要订购有网站吗?淘宝收费淘宝卖东西收多少手续费深圳公交车路线深圳公交车路线中小企业信息化信息化为中小企业发展带来了哪些机遇iphone越狱后怎么恢复苹果手机越狱后怎么恢复天天酷跑刷金币如何使用八门神器给天天酷跑刷钻刷金币畅想中国淄博畅想中国消费怎么样迅雷云点播账号求一个迅雷云点播vip的账号,只是看的,绝不动任何手脚。2012年正月十五山西省太原市2012年正月十五活动的相关情况宽带接入服务器目前常见宽带接入的方式有哪几种
动态域名解析 域名升级访问中 vps教程 国外idc gitcafe directadmin 360抢票助手 免费静态空间 绍兴高防 帽子云 php空间购买 umax120 美国独立日 网购分享 lick 贵阳电信测速 云服务器比较 创速 网络速度 葫芦机 更多