Oracle and MySql declaration variables and assignments

Variables in mysql do not need to be declared in advance, and they can be used directly with "@variable name" when they are used.

The first usage: set @num=1; or set @num:=1; //Here to use variables to save data, use the @num variable directly

The second usage: select @num:=1; or select @num:=field name from table name where  …

Pay attention to the above two assignment symbols, you can use "=" or ":=" when using set, but you must use ":= assignment" when using select

example:
SET @roleid=replace(uuid(), '-', '');
SET @userid=replace(uuid(), '-', '');

Variables in Oracle are declared in advance

example:

declare
  roleid varchar2(32);
  userid varchar2(32);
begin
  roleid:=sys_guid();
  userid:=sys_guid();

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326235720&siteId=291194637