ylbtech-SQL Server-Basic:SQL Server-数据库查询语句基本查询

SQL Server 数据库查询语句基本查询。

1,数据库查询语句基本查询
 
数据库 SQL Server Oracle
基本语句    
select

select * from titles

select title_id,title,price,pub_id from titles

select * from title where title_id=9834

select * from title order by price

select * from authirs order by a_lname,a_fname

select type,count(title_id)as 每种类型数量 from title group by type

注意:where 在前 order by 其次 group by 最后

同左←
delete delete into title where title_id=9874 同左←
update update title set title=title1,price=price1 where title_id=9874 同左←
insert

insert titles(,,,,) values(,,,,)

insert titles(title,price) values('thanks to java',23.5)

同左←
建视图    
  create view view_name
as

sql语句
 
建存储过程    
  create procdure proc_name
as
sql语句
 
有参数(只有入参) create proc ups_shj
@pub_id varchar(20)
as
select * from titles where pub_id=@pub_id;
 
有参数(入参,出参output)

create proc ups_shj1
@title varchar(200),
@ytd_sales int output
as
select @ytd_sales=ytd_sales from titles where title=@title;

--执行存储过程,查找书籍'Sushi, Anyone?'
go
declare @sales int
exec ups_shj1 'Sushi, Anyone?',@ytd_sales=@sales output
select @sales

 
     

作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

T-SQL:SQL Server-数据库查询语句基本查询的更多相关文章

  1. SQL server 数据库基础语句 子查询 基础函数

    上一章 说了下   子查询的意义是 把一条查询语句当做值来使用 select *from car   //查询汽车的信息 假设我知道一个汽车的编号是 c021 但是我要查询 比这个汽车价格高的汽车信息 ...

  2. SQL查询语句,怎样查询重复数据

    SQL查询语句,怎样查询重复数据 2012-02-22 14:50神奇的马骁勇 | 浏览 0 次 有表A, 中有字段id, name, memo现在有很多id重复的数据,怎么把这些重复的都查出来?gr ...

  3. SQL server 数据库基础语句 查询语句

    这一章要学习查询语句 我看car这一数据 我们就开始打上 select  *from car 条件修改 update 表名 set 列名1=值1 where 列名2=值2   //当列名2=值2时   ...

  4. SQL Server数据库阻塞,死锁查询

    sql 查询卡顿数据库 SELECT SPID=p.spid, DBName = convert(CHAR(20),d.name), ProgramName = program_name, Login ...

  5. access建立sql查询语句运行查询语句

    1.打开一个Access数据库文件 2.点击“创建”标签中的“查询设计”,会弹出一个“显示表”的对话框,点击“关闭”将其关闭 3.这时会有一个名为“查询*”的窗口,还不能输入SQL语句 4.点击左上角 ...

  6. 数据库---T-SQL语句:查询语句(二)

    >查询: 一.查询所有数据: select * from Info    ---查询所有数据(行) select Name from Info  ---查询特定列(Name列) select N ...

  7. mysql查询语句select-子查询

    1 子查询定义 在一个表表达中可以调用另一个表表达式,这个被调用的表表达式叫做子查询(subquery),我么也称作子选择(subselect)或内嵌选择(inner select).子查询的结果传递 ...

  8. SQL server数据库表碎片比例查询语句

    For rebuilding index, here is also a script to figure out the fragmentation and decide whether rebui ...

  9. SQL server 数据库 操作及简单查询

    使用SQL Sever语言进行数据库的操作 常用关键字identity 自增长primary key 主键unique 唯一键not null 非空references 外键(引用) 在使用查询操作数 ...

随机推荐

  1. Linux Shell查看磁盘分区,内存使用,CPU使用率

    Linux Shell查看磁盘分区,内存使用,CPU使用率 #!/bin/bash #disk_used_rate Location=/dev/xvdb Disk_Used_Rate=$(df -h ...

  2. 给View换字体

    注意,给View换字体是直接换.在Delegate里换的只是某一列的字体 class delegate : public QStyledItemDelegate { public: ) : QStyl ...

  3. QTableView带可编辑进度条

    main文件与上一个例子完全一致,也使用QStandardItemModel,关键是有这句:QStandardItem.setEditable(false);  继承QAbstractItemDele ...

  4. Android:开发环境

    一.JAVA SDK(JDK)的安装 http://www.cnblogs.com/tinyphp/p/3664598.html 二.ADT-Bundle 包含了Eclipse.ADT插件和SDK T ...

  5. C 语言文件操作

    C 语言文件操作 1. 数据流:     程序与数据的交互以流的形式进行.fopen 即打开数据流,fclose 即刷新数据流.     所谓数据流,是一种抽象,表示这段数据像流一样,需要逐步接收,不 ...

  6. iOS:核心动画具体的类和协议的介绍

    核心动画类:CAAnimation.CAPropertyAnimation.CABasicAnimation.CAKeyframeAnimation.CATransition.CAAnimationG ...

  7. 利用Hessian如何实现Webservice

    利用Hessian如何实现Webservice [大] [中] [小] 发布人:圣才学习网  发布日期:2012-08-18 14:02  共966人浏览 Hessian是 一个轻量级的remotin ...

  8. struts2与struts1整合,Unable to load configuration. - interceptor-ref ... struts.xml

    struts.xml中为了与struts1的MVC模式整合,需要类似如下的拦截器的引用 <interceptor-stack name="integration"> & ...

  9. Eclipse集成Tomcat的配置步骤实例

    使用Eclipse开发B/S结构Web应用时,必须使用Web应用服务器,常见的应用服务器有Tomcat, Jboss, WebLogic, WebSphere, SUN System Applicat ...

  10. Support Library(5)在eclipse中导入SupportXXXDemos

    Support4Demos只用一个v4.,Support7Demos只要v13.jar, SupportAppNavigation只要一个v4.jar. Support7Demos 需要资源全部v7系 ...