sql_mode.result 9.43 KB
Newer Older
1 2 3 4 5 6 7
drop table if exists t1;
CREATE TABLE `t1` (
a int not null auto_increment,
`pseudo` varchar(35) character set latin2 NOT NULL default '',
`email` varchar(60) character set latin2 NOT NULL default '',
PRIMARY KEY  (a),
UNIQUE KEY `email` USING BTREE (`email`) 
unknown's avatar
unknown committed
8
) ENGINE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC;
9 10 11 12 13 14 15 16 17 18 19
set @@sql_mode="";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL auto_increment,
  `pseudo` varchar(35) character set latin2 NOT NULL default '',
  `email` varchar(60) character set latin2 NOT NULL default '',
  PRIMARY KEY  (`a`),
20
  UNIQUE KEY `email` USING BTREE (`email`)
21
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
22 23 24 25 26 27 28 29 30 31 32
set @@sql_mode="ansi_quotes";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	ANSI_QUOTES
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) NOT NULL auto_increment,
  "pseudo" varchar(35) character set latin2 NOT NULL default '',
  "email" varchar(60) character set latin2 NOT NULL default '',
  PRIMARY KEY  ("a"),
33
  UNIQUE KEY "email" USING BTREE ("email")
34
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
35 36 37 38 39 40 41 42 43 44 45
set @@sql_mode="no_table_options";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	NO_TABLE_OPTIONS
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL auto_increment,
  `pseudo` varchar(35) character set latin2 NOT NULL default '',
  `email` varchar(60) character set latin2 NOT NULL default '',
  PRIMARY KEY  (`a`),
46
  UNIQUE KEY `email` USING BTREE (`email`)
47 48 49 50 51 52 53 54 55 56 57 58 59
)
set @@sql_mode="no_key_options";
show variables like 'sql_mode';
Variable_name	Value
sql_mode	NO_KEY_OPTIONS
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL auto_increment,
  `pseudo` varchar(35) character set latin2 NOT NULL default '',
  `email` varchar(60) character set latin2 NOT NULL default '',
  PRIMARY KEY  (`a`),
  UNIQUE KEY `email` (`email`)
60
) ENGINE=MEMORY DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
61 62 63
set @@sql_mode="no_field_options,mysql323,mysql40";
show variables like 'sql_mode';
Variable_name	Value
64
sql_mode	NO_FIELD_OPTIONS,MYSQL323,MYSQL40,HIGH_NOT_PRECEDENCE
65 66 67 68 69 70 71 72
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL auto_increment,
  `pseudo` varchar(35) NOT NULL default '',
  `email` varchar(60) NOT NULL default '',
  PRIMARY KEY  (`a`),
  UNIQUE KEY `email` (`email`)
unknown's avatar
unknown committed
73
) TYPE=HEAP ROW_FORMAT=DYNAMIC
74
set sql_mode="postgresql,oracle,mssql,db2,maxdb";
75 76
select @@sql_mode;
@@sql_mode
77
PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER
78 79 80 81 82 83 84 85 86 87
show create table t1;
Table	Create Table
t1	CREATE TABLE "t1" (
  "a" int(11) NOT NULL,
  "pseudo" varchar(35) NOT NULL default '',
  "email" varchar(60) NOT NULL default '',
  PRIMARY KEY  ("a"),
  UNIQUE KEY "email" ("email")
)
drop table t1;
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
CREATE TABLE t1 (
a char(10),
b char(10) collate latin1_bin,
c binary(10)
) character set latin1;
set @@sql_mode="";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) default NULL,
  `b` char(10) character set latin1 collate latin1_bin default NULL,
  `c` binary(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
set @@sql_mode="mysql323";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) default NULL,
  `b` char(10) binary default NULL,
  `c` binary(10) default NULL
) TYPE=MyISAM
set @@sql_mode="mysql40";
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` char(10) default NULL,
  `b` char(10) binary default NULL,
  `c` binary(10) default NULL
) TYPE=MyISAM
drop table t1;
118 119 120 121 122
set session sql_mode = '';
create table t1 ( min_num   dec(6,6)     default .000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
123
  `min_num` decimal(6,6) default '0.000001'
124 125 126 127 128 129 130
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
set session sql_mode = 'IGNORE_SPACE';
create table t1 ( min_num   dec(6,6)     default 0.000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
131
  `min_num` decimal(6,6) default '0.000001'
132 133 134 135 136 137
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
create table t1 ( min_num   dec(6,6)     default .000001);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
138
  `min_num` decimal(6,6) default '0.000001'
139 140
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1 ;
141 142
set @@SQL_MODE=NULL;
ERROR 42000: Variable 'sql_mode' can't be set to the value of 'NULL'
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='';
show local variables like 'SQL_MODE';
Variable_name	Value
sql_mode	
CREATE TABLE t1 (p int not null auto_increment, a varchar(20), primary key(p));
INSERT t1 (a) VALUES 
('\\'),
('\n'),
('\b'),
('\r'),
('\t'),
('\x'),
('\a'),
('\aa'),
('\\a'),
('\\aa'),
('_'),
('\_'),
('\\_'),
('\\\_'),
('\\\\_'),
('%'),
('\%'),
('\\%'),
('\\\%'),
('\\\\%')
;
SELECT p, hex(a) FROM t1;
p	hex(a)
1	5C
2	0A
3	08
4	0D
5	09
6	78
7	61
8	6161
9	5C61
10	5C6161
11	5F
12	5C5F
13	5C5F
14	5C5C5F
15	5C5C5F
16	25
17	5C25
18	5C25
19	5C5C25
20	5C5C25
delete from t1 where a in ('\n','\r','\t', '\b');
select
masks.p,
masks.a as mask,
examples.a as example
from
t1 as masks
left join t1 as examples on examples.a LIKE masks.a
order by masks.p, example;
p	mask	example
1	\	\
6	x	x
7	a	a
8	aa	aa
9	\a	a
10	\aa	aa
11	_	%
11	_	a
11	_	x
11	_	\
11	_	_
12	\_	_
13	\_	_
14	\\_	\%
14	\\_	\%
14	\\_	\a
14	\\_	\_
14	\\_	\_
15	\\_	\%
15	\\_	\%
15	\\_	\a
15	\\_	\_
15	\\_	\_
16	%	%
16	%	a
16	%	aa
16	%	x
16	%	\
16	%	\%
16	%	\%
16	%	\a
16	%	\aa
16	%	\\%
16	%	\\%
16	%	\\_
16	%	\\_
16	%	\_
16	%	\_
16	%	_
17	\%	%
18	\%	%
19	\\%	\
19	\\%	\%
19	\\%	\%
19	\\%	\a
19	\\%	\aa
19	\\%	\\%
19	\\%	\\%
19	\\%	\\_
19	\\%	\\_
19	\\%	\_
19	\\%	\_
20	\\%	\
20	\\%	\%
20	\\%	\%
20	\\%	\a
20	\\%	\aa
20	\\%	\\%
20	\\%	\\%
20	\\%	\\_
20	\\%	\\_
20	\\%	\_
20	\\%	\_
DROP TABLE t1;
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
show local variables like 'SQL_MODE';
Variable_name	Value
sql_mode	NO_BACKSLASH_ESCAPES
CREATE TABLE t1 (p int not null auto_increment, a varchar(20), primary key(p));
INSERT t1 (a) VALUES 
('\\'),
('\n'),
('\b'),
('\r'),
('\t'),
('\x'),
('\a'),
('\aa'),
('\\a'),
('\\aa'),
('_'),
('\_'),
('\\_'),
('\\\_'),
('\\\\_'),
('%'),
('\%'),
('\\%'),
('\\\%'),
('\\\\%')
;
SELECT p, hex(a) FROM t1;
p	hex(a)
1	5C5C
2	5C6E
3	5C62
4	5C72
5	5C74
6	5C78
7	5C61
8	5C6161
9	5C5C61
10	5C5C6161
11	5F
12	5C5F
13	5C5C5F
14	5C5C5C5F
15	5C5C5C5C5F
16	25
17	5C25
18	5C5C25
19	5C5C5C25
20	5C5C5C5C25
delete from t1 where a in ('\n','\r','\t', '\b');
select 
masks.p,
masks.a as mask,
examples.a as example
from
t1 as masks
left join t1 as examples on examples.a LIKE masks.a
order by masks.p, example;
p	mask	example
1	\\	\\
6	\x	\x
7	\a	\a
8	\aa	\aa
9	\\a	\\a
10	\\aa	\\aa
11	_	%
11	_	_
12	\_	\%
12	\_	\a
12	\_	\x
12	\_	\\
12	\_	\_
13	\\_	\\%
13	\\_	\\a
13	\\_	\\_
14	\\\_	\\\%
14	\\\_	\\\_
15	\\\\_	\\\\%
15	\\\\_	\\\\_
16	%	%
16	%	\%
16	%	\a
16	%	\aa
16	%	\x
16	%	\\
16	%	\\%
16	%	\\a
16	%	\\aa
16	%	\\\%
16	%	\\\\%
16	%	\\\\_
16	%	\\\_
16	%	\\_
16	%	\_
16	%	_
17	\%	\%
17	\%	\a
17	\%	\aa
17	\%	\x
17	\%	\\
17	\%	\\%
17	\%	\\a
17	\%	\\aa
17	\%	\\\%
17	\%	\\\\%
17	\%	\\\\_
17	\%	\\\_
17	\%	\\_
17	\%	\_
18	\\%	\\
18	\\%	\\%
18	\\%	\\a
18	\\%	\\aa
18	\\%	\\\%
18	\\%	\\\\%
18	\\%	\\\\_
18	\\%	\\\_
18	\\%	\\_
19	\\\%	\\\%
19	\\\%	\\\\%
19	\\\%	\\\\_
19	\\\%	\\\_
20	\\\\%	\\\\%
20	\\\\%	\\\\_
DROP TABLE t1;
391 392 393 394 395 396 397 398 399 400 401 402 403 404
SET @@SQL_MODE='NO_BACKSLASH_ESCAPES';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\\b	a\\\"b	a'\\b	a'\\\"b
a\\b	a\\\"b	a'\\b	a'\\\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\\b	a\\\'b	a"\\b	a"\\\'b
a\\b	a\\\'b	a"\\b	a"\\\'b
SET @@SQL_MODE='';
SELECT 'a\\b', 'a\\\"b', 'a''\\b', 'a''\\\"b';
a\b	a\"b	a'\b	a'\"b
a\b	a\"b	a'\b	a'\"b
SELECT "a\\b", "a\\\'b", "a""\\b", "a""\\\'b";
a\b	a\'b	a"\b	a"\'b
a\b	a\'b	a"\b	a"\'b
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
set session sql_mode = 'NO_ENGINE_SUBSTITUTION';
create table t1 (a int) engine=isam;
ERROR HY000: The 'ISAM' feature is disabled; you need MySQL built with 'ISAM' to have it working
show create table t1;
ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1;
Warnings:
Note	1051	Unknown table 't1'
set session sql_mode = '';
create table t1 (a int) engine=isam;
Warnings:
Warning	1266	Using storage engine MyISAM for table 't1'
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
423 424 425 426
SET @@SQL_MODE='';
create function `foo` () returns int return 5;
show create function `foo`;
Function	sql_mode	Create Function
427
foo		CREATE FUNCTION `foo`() RETURNS int(11)
428 429 430 431
return 5
SET @@SQL_MODE='ANSI_QUOTES';
show create function `foo`;
Function	sql_mode	Create Function
432
foo		CREATE FUNCTION `foo`() RETURNS int(11)
433 434 435 436 437
return 5
drop function `foo`;
create function `foo` () returns int return 5;
show create function `foo`;
Function	sql_mode	Create Function
438
foo	ANSI_QUOTES	CREATE FUNCTION "foo"() RETURNS int(11)
439 440 441 442
return 5
SET @@SQL_MODE='';
show create function `foo`;
Function	sql_mode	Create Function
443
foo	ANSI_QUOTES	CREATE FUNCTION "foo"() RETURNS int(11)
444 445 446 447 448 449 450 451
return 5
drop function `foo`;
SET @@SQL_MODE='';
create table t1 (a int);
create table t2 (a int);
create view v1 as select a from t1;
show create view v1;
View	Create View
452
v1	CREATE ALGORITHM=UNDEFINED VIEW `v1` AS select `t1`.`a` AS `a` from `t1`
453 454 455
SET @@SQL_MODE='ANSI_QUOTES';
show create view v1;
View	Create View
456
v1	CREATE ALGORITHM=UNDEFINED VIEW "v1" AS select "t1"."a" AS "a" from "t1"
457 458 459
create view v2 as select a from t2 where a in (select a from v1);
drop view v2, v1;
drop table t1, t2;
460
SET @@SQL_MODE=@OLD_SQL_MODE;