1
drop table if exists t1,t2,t3;
2
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
3
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
4
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
5
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
6
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
7
ERROR 23000: Duplicate entry '16' for key 'PRIMARY'
8
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
25
`numeropost` bigint(20) unsigned NOT NULL default '0',
26
`icone` tinyint(4) unsigned NOT NULL default '0',
27
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
28
`contenu` text NOT NULL,
29
`pseudo` varchar(50) NOT NULL default '',
30
`date` datetime NOT NULL default '0000-00-00 00:00:00',
31
`ip` bigint(11) NOT NULL default '0',
32
`signature` tinyint(1) unsigned NOT NULL default '0',
33
PRIMARY KEY (`numeropost`,`numreponse`)
36
KEY `pseudo` (`pseudo`),
37
KEY `numreponse` (`numreponse`)
40
`numeropost` bigint(20) unsigned NOT NULL default '0',
41
`icone` tinyint(4) unsigned NOT NULL default '0',
42
`numreponse` bigint(20) unsigned NOT NULL auto_increment,
43
`contenu` text NOT NULL,
44
`pseudo` varchar(50) NOT NULL default '',
45
`date` datetime NOT NULL default '0000-00-00 00:00:00',
46
`ip` bigint(11) NOT NULL default '0',
47
`signature` tinyint(1) unsigned NOT NULL default '0',
48
PRIMARY KEY (`numeropost`,`numreponse`),
51
KEY `pseudo` (`pseudo`),
52
KEY `numreponse` (`numreponse`)
55
(numeropost,icone,numreponse,contenu,pseudo,date,ip,signature) VALUES
56
(9,1,56,'test','joce','2001-07-25 13:50:53'
58
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
59
SELECT 1618,icone,contenu,pseudo,date,signature,ip FROM t2
60
WHERE numeropost=9 ORDER BY numreponse ASC;
61
show variables like '%bulk%';
63
bulk_insert_buffer_size 8388608
64
INSERT INTO t1 (numeropost,icone,contenu,pseudo,date,signature,ip)
65
SELECT 1718,icone,contenu,pseudo,date,signature,ip FROM t2
66
WHERE numeropost=9 ORDER BY numreponse ASC;
68
create table t1 (a int not null);
69
create table t2 (a int not null);
70
insert into t1 values (1);
71
insert into t1 values (a+2);
72
insert into t1 values (a+3);
73
insert into t1 values (4),(a+5);
74
insert into t1 select * from t1;
87
insert into t1 select * from t1 as t2;
110
insert into t2 select * from t1 as t2;
133
insert into t1 select t2.a from t1,t2;
556
insert into t1 select * from t1,t1;
557
ERROR 42000: Not unique table/alias: 't1'
559
create table t1 (a int not null primary key, b char(10));
560
create table t2 (a int not null, b char(10));
561
insert into t1 values (1,"t1:1"),(3,"t1:3");
562
insert into t2 values (2,"t2:2"), (3,"t2:3");
563
insert into t1 select * from t2;
564
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
570
replace into t1 select * from t2;
577
CREATE TABLE t1 ( USID INTEGER UNSIGNED, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User CHAR(32) NOT NULL DEFAULT '<UNKNOWN>', NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL);
578
CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNED, State ENUM ('unknown', 'Access-Granted', 'Session-Active', 'Session-Closed' ) NOT NULL DEFAULT 'unknown', SessionID CHAR(32), User TEXT NOT NULL, NASAddr INTEGER UNSIGNED, NASPort INTEGER UNSIGNED, NASPortType INTEGER UNSIGNED, ConnectSpeed INTEGER UNSIGNED, CarrierType CHAR(32), CallingStationID CHAR(32), CalledStationID CHAR(32), AssignedAddr INTEGER UNSIGNED, SessionTime INTEGER UNSIGNED, PacketsIn INTEGER UNSIGNED, OctetsIn INTEGER UNSIGNED, PacketsOut INTEGER UNSIGNED, OctetsOut INTEGER UNSIGNED, TerminateCause INTEGER UNSIGNED, UnauthTime TINYINT UNSIGNED, AccessRequestTime DATETIME, AcctStartTime DATETIME, AcctLastTime DATETIME, LastModification TIMESTAMP NOT NULL, INDEX(USID,ServerID,NASAddr,SessionID), INDEX(AssignedAddr));
579
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
580
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
584
Type tinyint(3) unsigned NOT NULL auto_increment,
585
Field int(10) unsigned NOT NULL,
586
Count int(10) unsigned NOT NULL,
587
UNIQUE KEY Month (Month,Type,Field)
589
insert into t1 Values
590
(20030901, 1, 1, 100),
591
(20030901, 1, 2, 100),
592
(20030901, 2, 1, 100),
593
(20030901, 2, 2, 100),
594
(20030901, 3, 1, 100);
596
Month Type Field Count
602
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
606
create table t2(No int not null, Field int not null, Count int not null);
607
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
609
Warning 1048 Column 'No' cannot be null
610
Warning 1048 Column 'No' cannot be null
617
ID int(11) NOT NULL auto_increment,
618
NO int(11) NOT NULL default '0',
619
SEQ int(11) NOT NULL default '0',
623
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
624
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
628
create table t1 (f1 int);
629
create table t2 (ff1 int unique, ff2 int default 1);
630
insert into t1 values (1),(1),(2);
631
insert into t2(ff1) select f1 from t1 on duplicate key update ff2=ff2+1;
637
create table t1 (a int unique);
638
create table t2 (a int, b int);
639
create table t3 (c int, d int);
640
insert into t1 values (1),(2);
641
insert into t2 values (1,2);
642
insert into t3 values (1,6),(3,7);
647
insert into t1 select a from t2 on duplicate key update a= t1.a + t2.b;
652
insert into t1 select a+1 from t2 on duplicate key update t1.a= t1.a + t2.b+1;
657
insert into t1 select t3.c from t3 on duplicate key update a= a + t3.d;
663
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + 10;
664
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
665
ERROR 23000: Column 'a' in field list is ambiguous
666
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
667
ERROR 42S22: Unknown column 't2.a' in 'field list'
668
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
669
ERROR 42S22: Unknown column 't2.b' in 'field list'
671
create table t1(f1 varchar(5) key);
672
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
673
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
674
insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1;
681
create table t1(x int, y int);
682
create table t2(x int, z int);
683
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x);
684
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z);
685
ERROR 42S22: Unknown column 'z' in 'field list'
686
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
687
ERROR 42S22: Unknown column 't2.x' in 'field list'
689
CREATE TABLE t1 (a int PRIMARY KEY);
690
INSERT INTO t1 values (1), (2);
692
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
693
show status like 'Handler_read%';
700
Handler_read_rnd_next 1
703
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
704
f2 varchar(100) NOT NULL default ''
707
f1 varchar(10) NOT NULL default '',
708
f2 char(3) NOT NULL default '',
710
KEY `k1` (`f2`, `f1`)
712
INSERT INTO t1 values(NULL, '');
713
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
714
SELECT COUNT(*) FROM t1;
717
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
720
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
721
SELECT COUNT(*) FROM t1;
728
CREATE TABLE t1 (x int, y int);
729
CREATE TABLE t2 (z int, y int);
730
CREATE TABLE t3 (a int, b int);
731
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
732
DROP TABLE IF EXISTS t1,t2,t3;
733
CREATE DATABASE bug21774_1;
734
CREATE DATABASE bug21774_2;
735
CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
736
CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
737
CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
738
INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
740
INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
741
DROP DATABASE bug21774_1;
742
DROP DATABASE bug21774_2;
744
create table t1(f1 int primary key, f2 int);
745
insert into t1 values (1,1);
747
insert into t1 values (1,1) on duplicate key update f2=1;
749
insert into t1 values (1,1) on duplicate key update f2=2;
755
CREATE TABLE t1 (f1 INT, f2 INT );
756
CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT);
757
INSERT INTO t1 VALUES (1,1),(2,2),(10,10);
758
INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1;
759
INSERT INTO t2 (f1, f2)
760
SELECT f1, f1 FROM t2 src WHERE f1 < 2
761
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
768
CREATE TABLE t1 ( a INT KEY, b INT );
769
INSERT INTO t1 VALUES ( 0, 1 );
770
INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
771
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
773
SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
774
CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
775
CREATE TABLE t2 (d VARCHAR(10));
776
INSERT INTO t1 (c) VALUES ('7_chars'), ('13_characters');
778
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
779
id select_type table type possible_keys key key_len ref rows Extra
780
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
781
2 SUBQUERY t1 ref ix_c ix_c 13 const 1 Using where
782
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
783
(SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters')
787
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='13_characters') FROM t1;
789
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c='7_chars') FROM t1;
791
SELECT (SELECT SUM(LENGTH(c)) FROM t1 WHERE c IN (SELECT t1.c FROM t1))
803
id INT AUTO_INCREMENT PRIMARY KEY,
805
join_id INT DEFAULT 0);
806
INSERT INTO t1 (prev_id) VALUES (NULL), (1), (2);
812
CREATE TABLE t2 (join_id INT);
813
INSERT INTO t2 (join_id) VALUES (0);
814
INSERT INTO t1 (prev_id) SELECT id
815
FROM t2 LEFT JOIN t1 ON t1.join_id = t2.join_id
816
ORDER BY id DESC LIMIT 1;
825
# Bug#30384: Having SQL_BUFFER_RESULT option in the
826
# CREATE .. KEY(..) .. SELECT led to creating corrupted index.
828
create table t1(f1 int);
829
insert into t1 values(1),(2),(3);
830
create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1;
831
check table t2 extended;
832
Table Op Msg_type Msg_text
833
test.t2 check status OK
835
##################################################################
837
# Bug #46075: Assertion failed: 0, file .\protocol.cc, line 416
839
CREATE TABLE t1(a INT);
840
SET max_heap_table_size = 16384;
841
SET @old_myisam_data_pointer_size = @@myisam_data_pointer_size;
842
SET GLOBAL myisam_data_pointer_size = 2;
843
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
844
call mtr.add_suppression("mysqld: The table '.*#sql.*' is full");
845
INSERT IGNORE INTO t1 SELECT t1.a FROM t1,t1 t2,t1 t3,t1 t4,t1 t5,t1 t6,t1 t7;
846
Got one of the listed errors
847
SET GLOBAL myisam_data_pointer_size = @old_myisam_data_pointer_size;