我们今天学习了数据库的语言先说一下添加一列:
alter table 表名 add 列名 类型 (长度)null;
Alter table users add age int; Null,
1.更改列类型
Alter table teacher alter colum age varchar(3);
2.删除一列:
Alter table users drop column age;
3.主键约束:
Alter table users add constraint 主键别名 primary key(id);
4.唯一键约束:
Alter table users add constraint 唯一键别名 unique(name);
5.默认键约束:
Alter table users add constraint 默认键 default (‘男’)for sex;
检查键约束:
Alter table users add constraint 检查键 check(age>=15and age<=40);
6.外键约束:
Alter table 表名1 add constraint 外键别名 foreignkey(外键) reference(表名2,主键);
7.删除约束:
alter table score drop constraint 删除键别名;
声明:此篇文档时来自于【狗刨学习网】社区-unity极致学院,是网友自行发布的Unity3D学习文章,如果有什么内容侵犯了你的相关权益,请与官方沟通,我们会即时处理。
8.数据库的具体创建:
Creat database 数据库名
On primary
(
Name= 数据文件别名(t_tk),
Filename =’d:\data\data.mdf,’
Size =25mb,
Maxsize=50mb,
Filegrowth=2mb,
)
Log on
(
Name =’third_ldf,' //日志文件别名
Size =5mb
Maxsize=25mb
Fiegrowth=10%
)
我又复习了一下以前的知识构造方法的格式和返回值的格式。
9.构造方法的格式:
[code]Class text {
Int c=5,d=6;
Public sum(int a){
a=c+d;
Console.WriteLine();
}
Public sum(string b){
b=c-d;
Console.writeLine();
}
}
Static void Main(string []args){
Text o=new text();
O.sum(6);
O.sum(“9”);
Console.ReadKey();
}[/code]
10.返回值格式:
Class stu{
[code]Int a=8,b=9,c;
Public void get(){
c=a+b;
Return c;
}
}
Static void Main(string [] args){
Stu p=new stu();
P.get(5);
Console.ReadKey();
}[/code]