1)Udu SQL语句创建一个表:例如:create table preson(id int not null,name nvarchar(50),age int null)
2)SQL语句删除一个表:drop table preson
3)给数据库里面插入数据:insert into person (number,name,age,nickname) values(3,’张三’,30,’aaa’);也可以这样写,省略字段:insert into person values(3,’张三’,30,’aaa’);尽量不要省略字段,省略字段的能看懂就行了.
4)SQL主要分DDL(数据定义语言)和DML(数据操作语言)两类.create table. Drop table等属于DDL,select . Insert等属于DML.
5)Sql中两种常用的主键数据类型:int(或bigint)+标识列(又称自动增长字段);uniqueidentifier(又称Guid。UUID).
6)SQLServe中生成GUID的函数select newid().在.net中生成GUID的方法:Guid.NewGuid();返回值是Guid类型.
7)SQL语句更新一个或多个列:update person set Age=30;
8)Update person set NickName=N’青年人’ where age>=20;过滤语句,当满足where后面的条件时,前面NickName才会执行.当有中文出现时前面要加个N,如NickName=N’青年人’ 或者:or
9)删除一个或多个列:delete from person; delete from person where age>20;
10)简单的数据检索:select * from person;星号表示所有
11)只检索需要的列:select Fnumber from person;检索Fnumber的列.selece Fname,Fage from person
12)给列取别名:select Fnumber as 编号,Fname as 姓名 from person.
13)使用where 检索符合条件的数据:select Fname from person where FSalary<5000;检索工资小于5000块钱的