sql数据库的操作

欢迎来到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

  二.arrylist
  特点:
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();
            
        }

    }



 

 

   

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值