mysql add column
ALTER TABLE table_name
ADD [COLUMN] column_name column_definition [FIRST|AFTER existing_column];
mysql add column
ALTER TABLE table_name
ADD [COLUMN] column_name column_definition [FIRST|AFTER existing_column];
add column to all tables after first column mysql
SELECT CONCAT('ALTER TABLE ', table_schema,'.', TABLE_NAME,' ADD COLUMN `hash` VARCHAR(50) NULL DEFAULT UUID() AFTER ', first_column, ';') AS ddl
FROM (
SELECT
(
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`=t.TABLE_SCHEMA AND `TABLE_NAME`=t.TABLE_NAME
LIMIT 1
) AS 'first_column',
t.*
FROM
information_schema.tables t
WHERE table_schema = 'your_table_name' AND table_type = 'base table'
) AS x;
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