数据库sql语句大全

数据库sql语句有哪些呢?下面就让我们一起来了解一下吧:

sql语句有很多,比较基本的sql语句有:

选择: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%’

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

总数: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

当然也还有其他的sql语句,具体介绍如下:

若是备份sql server

1、创建、备份数据的 device,示例代码为:

USE master

EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'

2、开始、备份,示例代码为:

BACKUP DATABASE pubs TO testBack

若是创建新表

示例代码为:

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

若是删除新表

示例代码为:

drop table tabname

以上就是小编的分享了,希望能够帮助到大家。

标签:sql语句 数据库

免责声明:本内容来自橡树街平台创作者或收集于互联网公开资源,不代表橡树街网的观点和立场。如有侵权内容,请联系我们删除。联系邮箱:ihuangque@qq.com
相关推荐
  • 数据库系统工程师一般什么专业
    数据库系统工程师一般什么专业
    08-05
  • 数据库系统工程师备考指南
    数据库系统工程师备考指南
    08-05
  • 数据库系统工程师看什么书
    数据库系统工程师看什么书
    08-05
  • 数据库系统工程师要买什么书
    数据库系统工程师要买什么书
    08-05
  • 数据库sql语句大全
    数据库sql语句大全
    08-05
  • 数据库怎么创建表
    数据库怎么创建表
    08-05
  • 数据库系统工程师需要哪些教材
    数据库系统工程师需要哪些教材
    08-05
  • 数据库系统工程师如何学起
    数据库系统工程师如何学起
    08-05
  • 数据库系统工程师一年可以考几次
    数据库系统工程师一年可以考几次
    08-05
  • 数据库触发器怎么写
    数据库触发器怎么写
    08-05