MariaDB [turqus]> show create table enum_field\G
*************************** 1. row ***************************
Table: enum_field
Create Table: CREATE TABLE `enum_field` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`col1` char(1) DEFAULT NULL,
`col2` char(1) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `enum_to` (`col1`,`col2`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1
MariaDB [turqus]> show create table temp_table\G
*************************** 1. row ***************************
Table: temp_table
Create Table: CREATE TEMPORARY TABLE `temp_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`random_value` varchar(20) DEFAULT NULL,
`random_value2` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
delimiter //
MariaDB [turqus]> show create procedure procx\G
*************************** 1. row ***************************
Procedure: procx
sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Procedure: CREATE DEFINER=``@`localhost` PROCEDURE `procx`()
begin
update temp_table set random_value = 'Tak' where random_value='t';
update temp_table set random_value = 'Nie' where random_value='f';
update temp_table set random_value2= 'Tak' where random_value2='t';
update temp_table set random_value2= 'Nie' where random_value2='f';
end
character_set_client: utf8
collation_connection: utf8_unicode_ci
Database Collation: latin1_swedish_ci
delimiter ;
MariaDB [turqus]> insert into temp_table (random_value,random_value2)
select enum_field.col1,enum_field.col2
from enum_field;
Po wywołaniu procedury tym poleceniem:
call procx;
W tabeli tymczasowej, która będzie istnieć tylko do ostatniej sesji, czyli najprawdopodobniej do zresetowania server'a MySQL dane zostaną zamienione.
Nie da się chyba założyć alias'u na wartość w tabeli.