数据库A,表B
创建数据库
CREATE DATABASE A
删除数据库
drop database A
创建表
Create table B([date] Date,[time] NVARCHAR(100),[0] int,[1] int)
插入表
插入B表数据:
INSERT INTO dbo.B
( dateandtime,tezheng, Value )
VALUES ( GETDATE(),
N'0',
1257
)
删除新表
drop table B
基本的sql语句
选择:select *fromtable1 where 范围
插入:insertintotable1(field1,field2) values(value1,value2)
删除:deletefromtable1 where 范围
更新:updatetable1 setfield1=value1 where 范围
查找:select *fromtable1 where field1 like ’%value1%’ ---like的语法很精妙,查资料!
排序:select *fromtable1 order by field1,field2 [desc]
总数:selectcount * astotalcount from table1
求和:selectsum(field1)as sumvalue from table1
平均:selectavg(field1)as avgvalue from table1
最大:selectmax(field1)as maxvalue from table1
最小:selectmin(field1)as minvalue from table1
外连接查询(表名1:a 表名2:b)
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFTOUT JOIN b ON a.a = b.c
随机取出10条数据
select top 10 * from tablename order by newid()