Answers for "how many coloumn add mysql table"

SQL
0

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;
Posted by: Guest on August-10-2021
0

how to add more columns to a table in mysql

CREATE TABLE IF NOT EXISTS vendors (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255)
);
ALTER TABLE vendors
ADD COLUMN phone VARCHAR(15) AFTER name;
Posted by: Guest on March-16-2021

Code answers related to "how many coloumn add mysql table"

Code answers related to "SQL"

Browse Popular Code Answers by Language