欢迎来到unity学习、unity培训、unity企业培训教育专区,这里有很多U3D资源、U3D培训视频U3D教程、U3D常见问题、U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。
这里以一个teacher 表进行的举例:
--删除表
truncate table teacher
--增加一列
alert table teacher add age int null
--更改列的类型
alter table teacher alter column age varchar(3)
--删除一列
alter table teacher drop column age
--为teacher表添加主键约束
alter table teacher add constraint t_pk primary key(id)
--为teacher表添加唯一的约束name
alter table teacher add constraint t_un unique(name)
--为teacher表中sex添加默认约束
alert table teacher add constraint t_li default ('nan') for sex
--为 teacher 表中的age添加检查约束
alter table teacher add constraint t_qw check(age>=15and age<=40)
--为teacher 和users表添加关联
alter table teacher add constraint t_fk foreign key(uid) references users(id)
--删除约束
alter table teacher drop constraint t_pk
特点: 1、有序的对象列表。
2、没有固定的大小,可以根据需要不断增长。
3、默认大小为16个元素,当添加第17个元素时会自动扩展到32个。
4、可以显示的指定其容量。
5、可以存储不同类型的元素,因为所有arrylist中的元素都是对象。
class Class3
{
public void Get() {
int[] a = new int[6] { 1, 2, 8, 7, 9, 5 };
ArrayList list = new ArrayList();
list.Add(100);
foreach (int b in a) {
list.Add(b);
}
list.Sort();
list.Remove(100);
foreach (int c in list) {
Console.WriteLine(c);
}
}
static void Main(string [] args) {
Class3 t = new Class3();
t.Get();
Console.ReadKey();
}
}下面的这个是有封装的集合
class Class1
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
}class Class2
{
public void GetNum()
{
List <Class1 > list=new List<Class1>() ;Class1 t = new Class1();
t.Age =20;
t.Name = "小红";
Class1 a = new Class1();
a.Name = "小黄";
a.Age = 30;
list.Add(t);
list.Add(a);
foreach (Class1 h in list ){
Console.WriteLine(h.Name +" "+h.Age );
}
}
static void Main(string[] args)
{
Class2 t= new Class2();
t.GetNum();
Console.ReadKey();
}}