设为首页 加入收藏

TOP

Beego 学习比较8:SQL语句
2017-12-07 14:22:13 】 浏览:1044
Tags:Beego 学习 比较 SQL 语句

SQL语句

1>     常用的SQL语句

     1->新增  insert into 表名(字段A,字段B,…) Values(字段A值,字段B值,…)

     2->更新  update 表名 set 字段A=字段A值,字段B=字段B值 where 条件

     3->删除  delete from 表名 where 条件

2>     单表SQL查询语句

    1-> SQL书写的顺序:select (distinct) 字段A,字段B,… from 表名 where 条件A  group by 字段C  having条件B order by 字段D (asc,desc)

    2->SQL执行的顺序: from表名where条件A group by字段C  having 条件B select (distinct) 字段A,字段B,… order by 字段D (asc,desc)

3>     多表操作SQL语句

   1->完全连接  select  a.字段A,a.字段B,b.字段A,b.字段B from 表名 a,表名b where a. 关联字段=b.关联字段

   2->左连接  select  a.字段A,a.字段B,b.字段A,b.字段B  from   a   left   join   b     on  a. 关联字段=b.关联字段        

   3->右连接  select  a.字段A,a.字段B,b.字段A,b.字段B   from   a   right   join   b     on   a. 关联字段=b.关联字段

   4->内连接  select  a.字段A,a.字段B,b.字段A,b.字段B  from  a   inner  join  b    on  a. 关联字段=b.关联字段    

4>     存储过程

  create proc | procedure pro_name

    [

    {@参数数据类型} [=默认值] [output],

     {@参数数据类型} [=默认值] [output],

     ....

    ]

  as

    SQL语句

  Go

   查看结果:exec  proc_ name  [参数A的值,参数B的值,…]

5>     触发器

    1->创建触发器

      create  trigger  trigger_name

      on {table_name | view_name}

      {for | After | Instead of }

      [ insert, update,delete ]

      as

        SQL语句

     Go

     理解:在那张表/那个视图上创建了一个触发器,这个触发器是在SQL执行语句的之后/还是替代SQL语句执行,触发器的类型是insert(插入),update(更新),delete(删除)

   2->删除触发器:

   基本语句如下:

  drop trigger trigger_name

6>     下一章记录使用BootStrap布局

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Beego学习笔记6:分页的实现 下一篇Beego学习笔记5:MVC-VC

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目