• T-SQL:SQL Server-数据库查询语句基本查询


    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

     
         
    warn 作者:ylbtech
    出处:http://ylbtech.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    SQL语句优化(转)
    ConcurrentHashMap源码分析
    centos 上安装gearman
    从与UCenter集成的过程中,看到Discuz的不开放
    UCenter实现同步登陆
    讨人喜欢的 MySQL replace into 用法(insert into 的增强版)
    Truncate Table
    mysql中key 、primary key 、unique key 与index区别
    PHP登录时限
    用Fragment实现如新浪微博一样的底部菜单的切换
  • 原文地址:https://www.cnblogs.com/ylbtech/p/3493855.html
Copyright © 2020-2023  润新知