一、数据类型:
1.整型:
java SQLServer
long bigbit
int int
smallint short
byte[-128,127] tinyint[0,255]
N/A bit
2.实型:
Java SQLServer
float real
double float
3.时间点:
datetime[1753-9999]
smalltime[1900-2079]
4.货币:
money
smallmoney[-214.748-214.748]
5.字符:
单字节 双字节
char nchar
varchar nvarchar
text ntext
6.唯一标识符
uniqueidentifier
7.image
图片 流媒体
二、运算符
1.四则运算
+ - * / %
2.逻辑运算
and or not
3.比较运算符
>, <, >=, <=, !=, <>
4.范围运算
[a , b]
三、别名标识
XXX
'XXX'
as 'XXX'
'XXX' =
四、常用数学函数
1.select pi() go
2.select power() go
3.select square() go
4.select log(), log10() go
5.select rand() go --[0 , 1)
6.select ceiling() , floor() go
五、常用字符串函数
1.select len() go
2.select left(str , n) , right(str , n) go
3.select ascii() --- char()
unicode() --- nchar()
4.select reverse(str) go
5.substring(str , start , length)
六、常用日期函数
select getdate() go
select year(getdate()) go
七、变量:
全局变量 @@修饰
局部变量 @修饰
创建步骤:
declare @a int ,@b float ,@c char;
set @a=1 ;
select @b=2.3 , @c='hello' ;
八、循环
结构:
while [条件]
begin
……
end
--set declare之后有分号
九、强制转换
select cast(a as b) go
--在sql中不允许将字符串和整数直接连接