首页 何问起 前端特效 htbtn-4 闪电 使用方法

MySql基础整理

http://hovertree.com/menu/mysql/

use abccs;
select * from mytable2 limit 3,4;
call sp_name1(1,@nn);
select @nn;
select length('sdaf');

select sum(1) from mytable2 where mytable2.name='8';
select sum_hell('abv');
select * from t;
#描述表t结构
desc t;
#添加一列设置为主键
alter table t add id int,add primary key (id);
#删除列my_order
alter table t drop column my_order;--
alter table t add my_order char(1) default 'Y';
#修改表列类型
alter table t modify my_order varchar(10);
alter table t change my_order my_order char(1);
#修改表 列名address1 为id
alter table t change column  address1 id int;
#删除存储过程testName
drop procedure testName;
delimiter //
create procedure testName(in name varchar(10),out para varchar(10))
begin
    declare deName varchar(10);
    #NOT FOUND,SQLEXCEPTION,SQLWARNING
    declare continue handler for not found,sqlexception,sqlwarning set @sp2=10;#begin end;
    set @sp1=1;
        delete from t where id <10;
    set @sp1=2;
        insert into t values(2,3);
    set @sp1=3;
        insert into t values(2,3);
    set @sp1=4;
        select id into para from t;
end;
call testName(2,@a);
select @a, @sp1, @sp2;
//
delimiter //
create procedure testTration()
begin
    declare continue handler for not found,sqlexception,sqlwarning rollback;
    start transaction;
    insert into t values(3,'Y');
    insert into t values(4,'Y');
    commit;
end;
call testTration();

#用户变量
set @cvar=23;
##系统变量
#全局系统变量  
set global eee=234
#会话系统变量 
set @@var
# 单行注释
-- 单行注释
/*
多行注释
eeee
*/

 

http://www.cnblogs.com/roucheng/p/mysqlhanshu.html

posted @ 2016-05-30 12:42  roucheng  阅读(454)  评论(0编辑  收藏  举报