文档详情

sql 经典SQL语句 SQL语句大全 sql教程.pdf

发布:2018-04-14约1.86万字共33页下载文档
文本预览下载声明
SQL CREATE DATABASE database-name drop database dbname sql server device USE master EXEC sp_addumpdevice disk, testBack, c:\mssql7backup\MyNwi nd_1.dat BACKUP DATABASE pubs TO testBack create table tabname(col1 type1 [not null] [primary key],col2 typ e2 [not null],..) create table tab_new like tab_old () create table tab_new as select col1,col2… from tab_old definiti on only 1 drop table tabname Alter table tabname add column col type DB2 varchar Alter table tabname add primary key(col) Alter table tabname drop primary key(col) create [unique] index idxname on tabname(col….) drop index idxname create view viewname as select statement drop view viewname 10sql select * from table1 where insert into table1(field1,field2) values(value1,value2) delete from table1 where update table1 set field1=value1 where select * from table1 where field1 like ’%value1%’ like ! select * from table1 order by field1,field2 [desc] 2 select count as totalcount from table1 select sum(field1) as sumvalue from table1 select avg(field1) as avgvalue from table1 select max(field1) as maxvalue from table1 select min(field1) as minvalue from table1 11 UNION UNION TABLE1 TABLE2 ALL UNION U NION ALL TABLE 1 TABLE2 EXCEPT EXCEPT TABLE1 TABLE2 ALL EXCEPT (EXCEPT AL L) INTERSECT INTERSECT TABLE1 TABLE2 ALL INTERSECT (INTERSEC T ALL) 12 left outer join
显示全部
相似文档