unity之数据库的基本操作和arrylist

哈喽,欢迎来到我们的 狗刨网,今天我们讲了很多有趣的东西,有数据库的约束,还有arrylist的应用,首先我们每天都会有新的更新,欢迎来到我们

的网站上看哦。

一、列的基本操作

增加一列

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

         例如:Alter  table student  add age int  null

更改列类型

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

         Alter  table  teacher alter column   age varchar(3)

删除列

         alter table 表名  drop  column 列名

         Alter  table  teacher drop   column  age
 
主键约束

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

         Alter  table  teacher add  constraint t_pk  primary key(id)

唯一约束

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

         Alter  table  teacher add  constraint  t_un  unique(name)

默认约束

         Alter  table 表名  add  constraint 默认键别名 default (‘默认值’) for 默认键

         Alter  table teacher  add  constraint t_de default('男')  for sex

检查约束

         Alter table 表名 add  constraint 检查键别名check(stuAge>=15  andstuAge<=40)

         Alter  table  teacher  add  constraint t_ch  check(age>=15 and age<=40)

删除约束

         Alter table 表名 drop constrant 约束别名

二、arrylist类

特点:1、有序的对象列表。

2、没有固定的大小,可以根据需要不断增长。

3、默认大小为16个元素,当添加第17个元素时会自动扩展到32个。

4、可以显示的指定其容量。

5、可以存储不同类型的元素,因为所有arrylist中的元素都是对象。

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

加上using System.Collections.Generic;

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

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

三、泛型集合

List<对象>

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

    list.Add("aaa");

            list.Add("bbb");

            list.Add("ccc");

            foreach (string i in list) {

                Console.WriteLine(i);

            }

2、ArrayList 的方法:

         --Add(object):把一个对象添加到 ArrayList 的末尾

         --Insert(index,object):在指定位置插入一个对象

         --Remove(object):移除一个对象

         --RemoveAt(index):移除一个对象

         --Clear():移除所有元素

         --Sort:对ArrayList 中的元素进行排序

这就是我们今天讲的主要内容,我们每天都会更新新的内容哟,欢迎来到我们的狗刨网,俗话说每天的进步就在于一点一滴的积累,每天自己进步多

一点,收获就非常大,欢迎来我们的 狗刨网看哟。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值