unity3D—列的基本操作和约束

来源:互联网 发布:win7编程界面 编辑:程序博客网 时间:2024/05/29 16:28
欢迎大家关注我的日志:

列的基本操作:

1.添加一列:

alter table 表名 add 列名 类型(长度) null

--alter  table  teacher  add  age  int  null


2.更改一列类型:

Alter  table 表名 alter column 列名 数据类型(长度)

  column:

--alter  table  teacher  alter  column  age  int


3.删除一列:

alter table 表名 drop column 列名

--alter  table  teacher  drop  column  age

 

4.主键约束:

alter table 表名 add  constraint 主键别名 primary key (主键列)

--alter  table  teacher  add  constraint  aw  primary  key(id)


5.唯一键约束:

alter table 表名 add  constraint 唯一键别名 unique (唯一键列)

--alter  table  teacher  add  constraint  ap  unique(name)--


6..默认键约束:

alter table 表名  add  constraint 默认键别名

default (‘默认值’) for 默认键

--alter  table  teacher  add  constraint t_ de  default('')  for  sex


7.检查键约束:

alter table 表名 add constraint 检查键别名

check(stuAge>=15 and stuAge<=40)

alter   table  teacher  add  constraint  ae  check(age>=15 and age<=40)


8.删除约束:

alter table 表名  drop constraint 约束别名

--alter  table  score  drop  constraint  ae

9. teacherusers表添加主外关联:


--Alter  table  score  add  constraint  es  foreign  key(uid) references  users(id)

-- insert  into  score(id,grade,uid)  values(1,85,110)


顺便简单介绍下ArrayListList的用法

ArrayList 很类似数组,但是ArrayList 类没有固定大小;可以根据需要不断增长默认大小为16个元素,当添加第17个元素时会自动扩展到32可以显式地指定其容量可以存储不同类型的元素, 因为所有ArrayList中的元素都是对象(System.Object)

加上using System.Collection

ArrayList al = new ArrayList();

int  a=new int[6] { 9, 3, 7, 2, 4, 8 } 

al.Add(100);//单个添加

 foreach (int number in a)   

 {

  al.Add(number);//集体添加

 }


List泛型集合可以约束集合内的元素类型,编译时检查类型约束,无需装箱拆箱操作

加上using System.Collections.Generic;

List<string> list=new List<string>();

List<Person> list = new List<Person>();

更多精彩可以关注:http://www.gopedu.com/

0 0