How to declare a variable and mysql update in liquibase

半城伤御伤魂 提交于 2019-12-02 03:18:32

The @value syntax is part of the MySQL SQL editor tools and not actually understood by the database itself so liquibase is not able to take advantage of them.

Liquibase does support similar functionality with changelog paramaters using the syntax ${value}

Aaron

If you want to declare and set variables within a changeset's 'sql' tag you just need to remove the ";".

By default liquibase uses ";" to execute, and variables are scoped within an execution. So while this will not work:

DECLARE @value1 varchar(10);
SET @value1 = "string1";

This will work:

DECLARE @value1 varchar(10)
SET @value1 = "string1"

I left off the last ";" on the initialization as I assume you want to do something with the variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!