菁英职教网 I T IT技术

sql查询语句

发布时间: 2022-03-03 17:34:13

精选答案

1、创建数据库

CREATE DATAbase database-name

2、删除数据库

drop database dbname

3、删除新表

drop table tabname

4、增加一个列

Alter table tabname add column col type

5、备份sql server

——创建 备份数据的 device

USE master

EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'

——开始 备份

BACKUP DATAbase pubs TO testBack

6、创建新表

create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)

根据已有的表创建新表:

A:create table tab_new like tab_old (用旧表创建新表)

B:create table tab_new as select col1,col2… from tab_old definition only

 

其他答案

选择:select * from table1 where 范围

删除:delete from table1 where 范围

插入: table1(field1,field2) values(value1,value2)

更新:update table1 set field1=value1 where 范围

查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料!

排序:select * from table1 order by field1,field2 [desc]

总数:select count as totalcount from table1

最大:select max(field1) as maxvalue from table1

最小:select min(field1) as minvalue from table1

求和:select sum(field1) as sumvalue from table1

平均:select avg(field1) as avgvalue from table1

温馨提示:
本文【sql查询语句】由作者职教君提供。该文观点仅代表作者本人,菁英职教网系信息发布平台,仅提供信息存储空间服务,若存在侵权问题,请及时联系管理员或作者进行删除。
我们采用的作品包括内容和图片部分来源于网络用户投稿,我们不确定投稿用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的权利,请联系我站将及时删除。
内容侵权、违法和不良信息举报
Copyright @ 2024 菁英职教网 All Rights Reserved 版权所有. 七品教育网站地图xml 留求艺网站地图xml 湘ICP备17021685号