set column to not null mysql
ALTER TABLE Person MODIFY P_Id INT(11) NOT NULL;
set column to not null mysql
ALTER TABLE Person MODIFY P_Id INT(11) NOT NULL;
add column if not exists mysql
SELECT count(*) INTO @EXIST
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'mydatabase'
AND COLUMN_NAME = 'mycolumn'
AND TABLE_NAME = 'mytable' LIMIT 1;
SET @query = IF (@exist <= 0, 'ALTER TABLE mydatabase.`mytable` ADD COLUMN `mycolumn` MEDIUMTEXT NULL',
'select ' COLUMN EXISTS' status');
PREPARE stmt FROM @query;
EXECUTE stmt;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us