maniu@securebrain.com:~# vi char_mysql







  # aggiungere queste righe nella sezione "[mysqld]" di /etc/my.cfn
  nit-connect='SET NAMES utf8'
  default-character-set=utf8
  character-set-server = utf8
  collation-server = utf8_general_ci


  # modifica al db preesistente per ripristinare le accentate (es. Bugzilla)

	--select a.*, b.bug_id from longdescs a , bugs_s2mon1.longdescs b
	--where a.bug_id=26
	--and a.bug_id = b.bug_id

	create table longdescs2 like longdescs;

	-- inserisco quelle diverse (troncate)
	insert into longdescs2
	select b.* from longdescs a , bugs_s2mon1.longdescs b
	where a.thetext <>  b.thetext
	and a.bug_id = b.bug_id
	and a.who = b.who
	and a.bug_when = b.bug_when
	;


	-- inserisco quelle uguali (corrette)
	insert into longdescs2
 	select b.* from longdescs a , bugs_s2mon1.longdescs b
 	where a.thetext = b.thetext
 	and a.bug_id = b.bug_id
 	and a.who = b.who
 	and a.bug_when = b.bug_when


	--select a.* from longdescs a left join longdescs2 b
	--on a.bug_id = b.bug_id
	--and a.who = b.who
	--and a.bug_when = b.bug_when
	--where b.bug_id is null

	-- inserisco quelle nuove (aggiunte dopo la migrazione)
	 insert into longdescs2
	 select a.* from longdescs a left join longdescs2 b
	 on a.bug_id = b.bug_id
	 and a.who = b.who
	 and a.bug_when = b.bug_when
	 where b.bug_id is null;

	--Query OK, 14 rows affected (0.05 sec)
	--Records: 14  Duplicates: 0  Warnings: 0


	-- SCAMBIO TABELLE:

	create table longdescs_bkup like longdescs;
	--Query OK, 0 rows affected (0.00 sec)

	 insert into longdescs_bkup
	   select * from longdescs;
	--Query OK, 688 rows affected (0.06 sec)
	--Records: 688  Duplicates: 0  Warnings: 0

	 delete from longdescs;
	--Query OK, 688 rows affected (0.01 sec)

	insert into  longdescs
	 select * from longdescs2;
	--Query OK, 688 rows affected (0.08 sec)
	--Records: 688  Duplicates: 0  Warnings: 0




:q!