mysql中变量不用事前申明,在用的时候直接用“@变量名”使用就可以了。
第一种用法:set @num=1; 或set @num:=1; //这里要使用变量来保存数据,直接使用@num变量
第二种用法:select @num:=1; 或 select @num:=字段名 from 表名 where ……
注意上面两种赋值符号,使用set时可以用“=”或“:=”,但是使用select时必须用“:=赋值”
example:
SET @roleid=replace(uuid(), '-', '');
SET @userid=replace(uuid(), '-', '');
Oracle中变量用事前申明
example:
declare
roleid varchar2(32);
userid varchar2(32);
begin
roleid:=sys_guid();
userid:=sys_guid();