成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

SQL Server學習筆記之一對多的刪除問題

數據庫 SQL Server
我們今天主要向大家講述的是SQL Server學習筆記之一對多的刪除問題,以下就是文章對其具體內容的詳細解析,望大家瀏覽之后會有所收獲。

以下的文章主要描述的是SQL Server學習筆記之一對多的刪除問題,假如你對其實際相關操作有興趣了解的話,下面的文章你一定不要錯過,望你在瀏覽完此篇文章之后會對你在今后的學習中有更好的了解。

Hibernate能支持MS SQL7.0嗎?

 

Hibernate深度探險!!----原創!

 

推薦圈子: Database圈子

更多相關推薦

1、create database school 創建數據庫school

 

2、drop database school 刪除數據庫school

3、use school 連接到school數據庫,使其成為當前數據庫

4、create table class(classID int primary key identity not null)

創建一個名為class的表,其有一個int型數據classID字段,該字段設置了主鍵約束

 

SQL Server學習筆記之并自動編號列且不能為空

 

5、select * from class 查詢class表中的所有字段

6、drop table class 刪除class表

7、select * into class2 from class

將class表中的所有數據復制到class2表中

 

8、select * into class2 from class where 1=0 只復制表結構

9、insert into class2(className) values('Juhn')或

insert into class2(className,tel) values('Bile','0731-2255664')

 

在class2表中插入一條記錄

 

10、delete from class2 where classID=2

刪除class2表中classID為2的行,如果指定where條件將刪除所有的行

 

 

delete from Student where StudentID between 13 and 15

 

刪除Student表中StudentID在13至15之間的數據(包括13和15)

 

11、alter table class2 add tel varchar(15) default('沒有電話')

修改表class2,為它添加一個tel列并將其默認值設為'沒有電話'

 

12、alter table class2 drop column tel 刪除列

13、alter table student add constraint telDefault default('沒有電話') for tel

SQL Server學習筆記之修改tel列的默認值

 

14、create table class3(classID int ,constraint id_key primary key(classID))

創建一個名為class3的表并為它設置了名為id_key的主鍵約束

 

15、unique 唯一約束

16、alter table class2 add age int check (age between 0 and 120)

為class2添一個age列,并為其設置檢查約束,使其的取值在0到120之間

 

17、alter table class2 add age int ,constraint ageCheck check

(age between 0 and 120)

 

其設置檢查約束方法二,為約束取名為ageCheck

 

18、alter table class2 add tel varchar(15) ,check

(tel like '[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9]')

 

其設置檢查約束方法三,此為模糊約束

 

19、create table class3(ID int primary key identity,classID int ,

name varchar(15) ,constraint classID foreign key(classID) references

 

class2(classID)) #p#

 

SQL Server學習筆記之設置外鍵約束

 

20、alter table class3 drop classID

刪除class3的classID外鍵約束

 

21、create index class2Name on class2(className)

在class2表的calssName字段上創建一個class2Name的索引

 

22、create unique index class2Name on class2(className)

SQL Server學習筆記之創建唯一索引

 

23、select classID,className from class2 where className='body'

select classID,className from class2 where className like '%s'

 

創建索引后查詢的的速度將更快,但會降低insert、update、delete的執行速度

 

24、drop index class2.class2Name 刪除表class2上的class2Name索引

25、update class2 set className='Lida',tel='13787277732' where classID=3

將class2表中className和tel列、classID=3

 

行的單元格的值改為'Lida'和'13787277732',注意忽略where語句將改變表中所有的行

 

26、create default sexDefault as '男'; 創建一個名為sexDefault的默認值

sp_bindefault sexDefault,'student.sex';

 

將創建的sexDefault默認值綁定到student表的sex字段上

 

27、insert into class2(name,names) select name,names from class1

將class1中的數據全部復制到class2中

 

28、truncate table class 刪除class表中所有的行

29、select Name 國家,Population 人口 from BBC where Name

in('France','Cermany','Italy United')

 

查詢BBC表中'France','Cermany','Italy United'三個地區的所在的國家和人口數

 

30、select Name 國家 from BBC where Name like '%United%'

查詢BBC表中的Name字段中包含United字符的國家,通配符"_"表示匹配任意單個字符

 

30、select Name 國家, Population 人口 from BBC where Population>100000000 order by Population desc

查詢BBC表中的Population字段大于100000000的國家和人口,并按降序排序,默認為升序asc

 

31、select Name,round(Population/1000000,0) as '人口(百萬)' from BBC where Region='South Asia'

查詢BBC表中的Region='South Asia'國家和百萬人口數(round是四舍五入)

 

32、select distinct Region from BBC

查詢BBC表中的Region字段中的非重復數據,distinct排除重復數據

 

如有多列則作用在列的組合上,而不再作用在單列上

 

33、select top 50 percent * from BBC

查詢BBC表中的所有字段,但只返回總行數的50%,percent表百分數、可選

 

34、select * from BBC where Area>100 and not GDP<10000000

查詢BBC表中的所有Area小于100并且GDP不小于10000000的數據,會返回所有的列,不只是Area列

 

33、select * from BBC where Area not between 20000 and 30000

查詢BBC表中的所有Area不在20000和30000之間的數據,會返回所有的列,不只是Area列

 

34、select distinct Name+str(Age) 學生 from Student

查詢Student表中Name和Age字段都不重復的數據

 

str(Age)返回Age的字符串表達形式,"學生"是別名

 

 

35、select * from Student where Nealth is null

 

查詢Student表中Nealth字段為null的數據

 

 

36、exec sp_helpconstraint 'Teacher'

 

SQL Server學習筆記之查看'Teacher'表中的所有約束

 

 

37、select * from Student where StudentID=1

 

for xml raw

 

返回XML語句

 

38、drop procedure MyProcedure

 

刪除一個存在的存儲過程

 

39、create procedure insert_Procedure

 

@Name varchar(10),

 

@Sex varchar(2),

 

@Age int,

 

@Tel varchar(20),

 

@Address varchar(50)

 

as

 

insert into student(Name,Sex,Age,Tel,Address) values(@Name,@Sex,@Age,@Tel,@Address)

 

創建一個插入數據的存儲過程

 

40、select datediff(day,'20090403',getdate())

 

用指定時間減去當前時間,返回的是天數,還可以用month返回月數

 

 

以上的相關內容就是對SQL Server學習筆記之一對多的刪除問題的介紹,望你能有所收獲。 

【編輯推薦】

  1. 實現SQL Server視圖的代碼有哪些?
  2. 實現SQL Server索引的代碼示例
  3. SQL Server創建約束的代碼運用
  4. SQL Server創建表所要用到的代碼
  5. SQL Server 2005商業智能功能淺析

 

責任編輯:佚名 來源: 清華大學出版社
相關推薦

2009-06-04 16:14:22

Hibernate一對Hibernate一對Hibernate多對

2009-09-22 09:55:58

Hibernate實例

2010-04-15 09:09:02

Hibernate

2009-07-21 17:31:39

iBATIS一對多映射

2022-02-18 11:05:25

Jpa配置Address

2011-08-17 10:28:53

多對多查詢SQL Server

2009-09-23 10:37:50

Hibernate一對

2010-07-08 12:52:58

SQL Server

2020-06-23 14:28:24

MySQL商品數據

2023-06-12 08:09:01

FlaskSQLAlchemy

2011-07-04 14:28:18

SQL Server分區

2009-09-23 10:57:02

Hibernate一對

2022-02-16 15:32:58

FlexUI框架容器組件

2010-06-28 12:46:09

SQL Server

2011-08-01 16:10:00

SQL Server

2012-06-27 10:28:12

編程語言語言學習多門語言

2011-02-28 13:19:50

SQL Server SQL死鎖

2010-10-21 11:10:57

SQL Server查

2009-12-23 09:31:11

寬帶路由上網故障

2010-07-15 14:55:05

SQL Server數
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产日韩欧美在线观看 | av第一页 | 羞视频在线观看 | 国产蜜臀97一区二区三区 | 都市激情亚洲 | 亚洲国产精品成人久久久 | 国产精品一区二区在线 | 国产欧美一区二区精品忘忧草 | 97视频在线免费 | 91中文字幕 | 亚洲午夜在线 | 亚洲免费一 | 日韩精品在线一区二区 | 亚洲麻豆 | 日本精品一区二区三区视频 | 日韩在线观看一区二区三区 | 龙珠z国语版在线观看 | 日本一区二区三区四区 | 亚洲免费大片 | 天天综合国产 | 国产乱码一二三区精品 | 亚洲第一视频 | 成人一区二区三区在线观看 | av片免费 | 草久久久 | 日日精品 | 91精品国产综合久久久久蜜臀 | 欧美国产日韩精品 | 一级片免费视频 | 午夜精品一区二区三区免费视频 | 成年男女免费视频网站 | 欧美成人一区二免费视频软件 | 黄色网毛片 | 欧美 日韩 国产 成人 在线 | 国产大片一区 | 国产精品美女久久久久久免费 | 欧美福利| 成人国内精品久久久久一区 | 日韩中文字幕在线视频 | 精品视频一区二区三区在线观看 | 激情福利视频 |