mysql 获取SQL语法错误,但我知道语法应该正确[已关闭]

xkftehaa  于 2023-02-28  发布在  Mysql
关注(0)|答案(1)|浏览(132)

4天前关闭。
Improve this question
Toad Syntax error

ALTER TABLE db_group ADD COLUMN IF NOT EXISTS `isPublic` tinyint(4) not null default 0;

ALTER TABLE db_group_point MODIFY COLUMN group_code varchar(50) NOT NULL DEFAULT 0 COLLATE utf8_bin;

-- ALTER TABLE db_group_point DROP PRIMARY KEY;
-- ALTER TABLE db_group_point ADD COLUMN ID int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT;
-- ALTER TABLE db_group_point ADD CONSTRAINT db_group_point_Contraint1 UNIQUE (group_code, TagName, TagOrder);

DROP PROCEDURE IF EXISTS UpgradeInsight3_1;
CREATE PROCEDURE UpgradeInsight3_1 ()
BEGIN

IF NOT EXISTS (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
    WHERE
      (table_name = 'db_group_point')
      AND (table_schema = 'prism')
      AND (column_name = 'ID'))
THEN 
  ALTER TABLE db_group_point DROP PRIMARY KEY;
  ALTER TABLE db_group_point ADD COLUMN IF NOT EXISTS ID int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT;
END IF;

IF NOT EXISTS (SELECT * FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME = 'db_group_point_Contraint1')
THEN
  ALTER TABLE db_group_point ADD CONSTRAINT db_group_point_Contraint1 UNIQUE (group_code, TagName, TagOrder);
END IF;

END;

CALL UpgradeInsight3_1();
DROP PROCEDURE IF EXISTS UpgradeInsight3_1;

ALTER TABLE db_group_point ADD COLUMN IF NOT EXISTS TagAlias  varchar(255) DEFAULT NULL  COLLATE utf8_bin;

INSERT IGNORE INTO sys_user_role(ROLE_ID,USER_ID) VALUES (1, 1);
ALTER TABLE sys_user
MODIFY COLUMN ADDRESS varchar(200) DEFAULT NULL COMMENT 'Address of user',
MODIFY COLUMN EMAIL varchar(200) DEFAULT NULL COMMENT 'Email of user',
MODIFY COLUMN POSITION varchar(200) DEFAULT NULL COMMENT 'Position of user in plant',
MODIFY COLUMN DESCRIPTION varchar(300) DEFAULT NULL COMMENT 'Description more about user';

DROP PROCEDURE IF EXISTS prism.sp_mimic_stringtag_latest_values;
DELIMITER //
CREATE PROCEDURE prism.`sp_mimic_stringtag_latest_values`(
    IN tagname1 varchar(255)
)

我试着删除默认值并添加其他内容。

mqkwyuun

mqkwyuun1#

那是因为

ADD COLUMN IF NOT EXISTS

据我所知,这个条款并不存在。

相关问题