摘要: 约束说明如下: create table Persons(id int primary key identity(1,1) , ---主键,自增长 id_p int not null unique CHECK (Id_P>0) --check , --唯一LastName varchar(255) not null , --null FirstName varchar(255),City varchar(255) default 'beijing', --defaultConstraint uc_FullName unique(FirstName,LastName) , 阅读全文
posted @ 2011-04-07 23:36 cnby 阅读(2368) 评论(0) 推荐(0) 编辑
摘要: SQL SELECT INTO 语句可用于创建表的备份复件。简单说明:select filed1,filed2 --要创建的新列into table1 --创建的新表名from table2 --要复制的表where 1=2 --要复制的数据,如果条件不成功则只复制表结构,没有数据从一个以上的表中选取数据也是可以做到的。下面的例子会创建一个名为 "Persons_Order_Backup" 的新表,其中包含了从 Persons 和 Orders 两个表中取得的信息:SELECT Persons.LastName,Orders.OrderNoINTO Persons_Orde 阅读全文
posted @ 2011-04-07 22:54 cnby 阅读(438) 评论(0) 推荐(0) 编辑
摘要: 1案例描述:从题库(保存了所有考试的题目)中抽出一样数量的题做为新的试卷,要求每次的试题顺序不同,这样也就没法抄了啊。 View Code --建立表createtableQuestions(intQuestionIDint,vchQuestionTextvarchar(512))gocreatetableTestQuestions(intQuestionIDint,vchQuestionTextvarchar(512))GO--插入数据declare@intCounterintdeclare@vchQuestionvarchar(64)setnocountonselect@intCounte 阅读全文
posted @ 2011-04-07 22:43 cnby 阅读(2650) 评论(1) 推荐(0) 编辑