I created this procedure
to test if there is a field in a database, if it does not exist, the procedure
would create.
DELIMITER ||
CREATE PROCEDURE sp_verificarLinhas(IN colunas VARCHAR(50)) BEGIN
IF NOT EXISTS (SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = Database() AND TABLE_NAME='prt_license' AND COLUMN_NAME
= colunas ) THEN SET @s = CONCAT('ALTER TABLE eco_portaldb.prt_license ADD COLUMN ', colunas ,' VARCHAR(100) NULL DEFAULT NULL AFTER date_update'); PREPARE stmt FROM @s; EXECUTE stmt;
end if; END ||
DELIMITER ;
When it finds some field that does not exist, it gives me the following error:
Syntax error or access violation: 1142 ALTER command denied to user 'eco_portaluserh'@'186.206.156.42' for table 'prt_license'
After removing it and trying to recreate it, it started to give me this error:
SQLSTATE [HY000]: General error: 1267 Illegal mix of collations (utf8_general_ci, IMPLICIT) and (utf8_unicode_ci, IMPLICIT) for operation '='
This piece has already been fixed transforming the database in general
The database, the table is as UTF8
. Already tried:
alter table 'prt_license' convert to character set utf8 collate utf8_general_ci