1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
|
########################
# BINARY columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
b BINARY NOT NULL,
b0 BINARY(0) NOT NULL,
b1 BINARY(1) NOT NULL,
b20 BINARY(20) NOT NULL,
b255 BINARY(255) NOT NULL,
pk BINARY PRIMARY KEY
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b binary(1) NO NULL
b0 binary(0) NO NULL
b1 binary(1) NO NULL
b20 binary(20) NO NULL
b255 binary(255) NO NULL
pk binary(1) NO PRI NULL
INSERT INTO t1 VALUES ('','','','','','');
INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b0' at row 1
Warning 1265 Data truncated for column 'b1' at row 1
Warning 1265 Data truncated for column 'b20' at row 1
Warning 1265 Data truncated for column 'b255' at row 1
INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
ERROR 23000: Duplicate entry 'c' for key 'PRIMARY'
SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 62
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
ALTER TABLE t1 ADD COLUMN b257 BINARY(257) NOT NULL;
ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b binary(1) NO NULL
b0 binary(0) NO NULL
b1 binary(1) NO NULL
b20 binary(20) NO NULL
b255 binary(255) NO NULL
pk binary(1) NO PRI NULL
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BINARY NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BINARY NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c binary(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
30
DROP TABLE t1;
#----------------------------------
# BINARY NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BINARY NOT NULL DEFAULT 0
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c binary(1) NO 0
ALTER TABLE t1 ADD COLUMN err BINARY NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 30
2 30
DROP TABLE t1;
########################
# VARBINARY columns
########################
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
v0 VARBINARY(0) NOT NULL,
v1 VARBINARY(1) NOT NULL,
v64 VARBINARY(64) NOT NULL,
v65000 VARBINARY(65000) NOT NULL,
PRIMARY KEY (v64)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varbinary(0) NO NULL
v1 varbinary(1) NO NULL
v64 varbinary(64) NO PRI NULL
v65000 varbinary(65000) NO NULL
CREATE TABLE t2 (v VARBINARY(65532) NOT NULL, PRIMARY KEY(v(255))) ENGINE=rocksdb;
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v varbinary(65532) NO PRI NULL
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
Warnings:
Warning 1265 Data truncated for column 'v0' at row 1
Warning 1265 Data truncated for column 'v1' at row 1
Warning 1265 Data truncated for column 'v64' at row 1
Warning 1265 Data truncated for column 'v65000' at row 1
INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 5
Warning 1265 Data truncated for column 'v1' at row 5
Warning 1265 Data truncated for column 'v64' at row 5
Warning 1265 Data truncated for column 'v0' at row 6
Warning 1265 Data truncated for column 'v1' at row 6
Warning 1265 Data truncated for column 'v64' at row 6
Warning 1265 Data truncated for column 'v65000' at row 6
SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
0
61 0
48 61486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E205765277665 5932
61 61616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364656667686920616263 130000
79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) NOT NULL;
Warnings:
Note 1246 Converting column 'v65536' from VARBINARY to BLOB
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varbinary(0) NO NULL
v1 varbinary(1) NO NULL
v64 varbinary(64) NO PRI NULL
v65000 varbinary(65000) NO NULL
v65536 mediumblob NO NULL
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
#----------------------------------
# VARBINARY(64) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARBINARY(64) NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varbinary(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test');
SELECT HEX(c) FROM t1;
HEX(c)
74657374
DROP TABLE t1;
#----------------------------------
# VARBINARY(64) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c VARBINARY(64) NOT NULL DEFAULT 'test'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varbinary(64) NO test
ALTER TABLE t1 ADD COLUMN err VARBINARY(64) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 74657374
2 74657374
DROP TABLE t1;
########################
# BIT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a BIT NOT NULL,
b BIT(20) NOT NULL,
c BIT(64) NOT NULL,
d BIT(1) NOT NULL,
PRIMARY KEY (c)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) NO NULL
b bit(20) NO NULL
c bit(64) NO PRI NULL
d bit(1) NO NULL
ALTER TABLE t1 DROP COLUMN d;
ALTER TABLE t1 ADD COLUMN d BIT(0) NOT NULL;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) NO NULL
b bit(20) NO NULL
c bit(64) NO PRI NULL
d bit(1) NO NULL
INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
BIN(a) HEX(b) c+0
0 FFFFF 18446744073709551615
INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
a+0 b+0 c+0
0 1048575 18446744073709551615
1 0 18446744073709551614
INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
a+0 b+0 c+0
1 0 18446744073709551614
1 102 255
DELETE FROM t1;
INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT a+0,b+0,c+0,d+0 FROM t1;
a+0 b+0 c+0 d+0
1 0 0 1
INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
Warnings:
Warning 1264 Out of range value for column 'c' at row 1
SELECT a+0,b+0,c+0,d+0 FROM t1;
a+0 b+0 c+0 d+0
1 0 0 1
1 0 18446744073709551615 0
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) NOT NULL) ENGINE=rocksdb;
ERROR 42000: Display width out of range for 'a' (max = 64)
DROP TABLE IF EXISTS t1;
#----------------------------------
# BIT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bit(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# BIT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BIT NOT NULL DEFAULT 1
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bit(1) NO b'1'
ALTER TABLE t1 ADD COLUMN err BIT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
########################
# BLOB columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
b BLOB NOT NULL,
b0 BLOB(0) NOT NULL,
b1 BLOB(1) NOT NULL,
b300 BLOB(300) NOT NULL,
bm BLOB(65535) NOT NULL,
b70k BLOB(70000) NOT NULL,
b17m BLOB(17000000) NOT NULL,
t TINYBLOB NOT NULL,
m MEDIUMBLOB NOT NULL,
l LONGBLOB NOT NULL
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
b blob NO NULL
b0 blob NO NULL
b1 tinyblob NO NULL
b300 blob NO NULL
bm blob NO NULL
b70k mediumblob NO NULL
b17m longblob NO NULL
t tinyblob NO NULL
m mediumblob NO NULL
l longblob NO NULL
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
('','','','','','','','','',''),
('a','b','c','d','e','f','g','h','i','j'),
('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5 6
65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b0' at row 1
Warning 1265 Data truncated for column 'b1' at row 1
Warning 1265 Data truncated for column 'b300' at row 1
Warning 1265 Data truncated for column 'bm' at row 1
Warning 1265 Data truncated for column 't' at row 1
SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5 6
65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BLOB NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c blob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# BLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BLOB NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c blob NO ''
ALTER TABLE t1 ADD COLUMN err BLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYBLOB NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TINYBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYBLOB NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyblob NO ''
ALTER TABLE t1 ADD COLUMN err TINYBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMBLOB NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# MEDIUMBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMBLOB NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumblob NO ''
ALTER TABLE t1 ADD COLUMN err MEDIUMBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# LONGBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGBLOB NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# LONGBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c LONGBLOB NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longblob NO ''
ALTER TABLE t1 ADD COLUMN err LONGBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
########################
# BOOL columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
b1 BOOL NOT NULL,
b2 BOOLEAN NOT NULL
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
b1 tinyint(1) NO NULL
b2 tinyint(1) NO NULL
INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
SELECT b1,b2 FROM t1;
b1 b2
1 1
INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
SELECT b1,b2 FROM t1;
b1 b2
0 0
1 1
INSERT INTO t1 (b1,b2) VALUES (2,3);
SELECT b1,b2 FROM t1;
b1 b2
0 0
1 1
2 3
INSERT INTO t1 (b1,b2) VALUES (-1,-2);
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
1 1
2 3
SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
a b
false false
true true
true true
true true
SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
b1 b2
1 1
SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
b1 b2
0 0
INSERT INTO t1 (b1,b2) VALUES ('a','b');
Warnings:
Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1
Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
0 0
1 1
2 3
INSERT INTO t1 (b1,b2) VALUES (128,-129);
Warnings:
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b2' at row 1
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
0 0
1 1
127 -128
2 3
ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED NOT NULL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED NOT NULL' at line 1
ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL NOT NULL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ADD COLUMN b3 BOOL ZEROFILL NOT NULL' at line 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BOOL NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BOOL NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('0');
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# BOOL NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BOOL NOT NULL DEFAULT '0'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(1) NO 0
ALTER TABLE t1 ADD COLUMN err BOOL NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('0');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# CHAR columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
c CHAR NOT NULL,
c0 CHAR(0) NOT NULL,
c1 CHAR(1) NOT NULL,
c20 CHAR(20) NOT NULL,
c255 CHAR(255) NOT NULL,
PRIMARY KEY (c255)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) NO NULL
c0 char(0) NO NULL
c1 char(1) NO NULL
c20 char(20) NO NULL
c255 char(255) NO PRI NULL
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
SELECT c,c0,c1,c20,c255 FROM t1;
c c0 c1 c20 c255
a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'c0' at row 1
Warning 1265 Data truncated for column 'c1' at row 1
Warning 1265 Data truncated for column 'c20' at row 1
Warning 1265 Data truncated for column 'c255' at row 1
INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'c' at row 5
Warning 1265 Data truncated for column 'c0' at row 5
Warning 1265 Data truncated for column 'c1' at row 5
Warning 1265 Data truncated for column 'c20' at row 5
Warning 1265 Data truncated for column 'c' at row 6
Warning 1265 Data truncated for column 'c0' at row 6
Warning 1265 Data truncated for column 'c1' at row 6
Warning 1265 Data truncated for column 'c20' at row 6
Warning 1265 Data truncated for column 'c255' at row 6
SELECT c,c0,c1,c20,c255 FROM t1;
c c0 c1 c20 c255
a
C C Creating an article aCreating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
x x xxxxxxxxxxxxxxxxxxxx axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
c20 REPEAT('a',LENGTH(c20)) COUNT(*)
2
Creating an article aaaaaaaaaaaaaaaaaaa 1
aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
ALTER TABLE t1 ADD COLUMN c257 CHAR(257) NOT NULL;
ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# CHAR NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c char(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('_');
SELECT HEX(c) FROM t1;
HEX(c)
5F
DROP TABLE t1;
#----------------------------------
# CHAR NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c CHAR NOT NULL DEFAULT '_'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c char(1) NO _
ALTER TABLE t1 ADD COLUMN err CHAR NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('_');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 5F
2 5F
DROP TABLE t1;
########################
# VARCHAR columns
########################
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
v0 VARCHAR(0) NOT NULL,
v1 VARCHAR(1) NOT NULL,
v64 VARCHAR(64) NOT NULL,
v65000 VARCHAR(65000) NOT NULL,
PRIMARY KEY (v64)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varchar(0) NO NULL
v1 varchar(1) NO NULL
v64 varchar(64) NO PRI NULL
v65000 varchar(65000) NO NULL
CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=rocksdb;
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v varchar(65532) NO PRI NULL
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
SELECT v0,v1,v64,v65000 FROM t1;
v0 v1 v64 v65000
y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Free to read in the Knowledgebase!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
* MariaDB Crash Course by Ben Forta
* MySQL (4th Edition) by Paul DuBois
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
* MySQL Admin Cookbook
* MySQL Cookbook by Paul DuBois
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
For MariaDB / MySQL end users
For developers who want to code on MariaDB or MySQL
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
Warnings:
Warning 1265 Data truncated for column 'v0' at row 1
Warning 1265 Data truncated for column 'v1' at row 1
Warning 1265 Data truncated for column 'v64' at row 1
Warning 1265 Data truncated for column 'v65000' at row 1
INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 5
Warning 1265 Data truncated for column 'v1' at row 5
Warning 1265 Data truncated for column 'v64' at row 5
Warning 1265 Data truncated for column 'v65000' at row 5
Warning 1265 Data truncated for column 'v0' at row 6
Warning 1265 Data truncated for column 'v1' at row 6
Warning 1265 Data truncated for column 'v64' at row 6
SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
v0 v1 v64 LENGTH(v65000)
0
a 0
H aHere is a list of recommended books on MariaDB and MySQL. We've 2966
a aabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abc 65000
y Once there, double check that an article doesn't already exist 2965
y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) NOT NULL;
Warnings:
Note 1246 Converting column 'v65536' from VARCHAR to TEXT
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varchar(0) NO NULL
v1 varchar(1) NO NULL
v64 varchar(64) NO PRI NULL
v65000 varchar(65000) NO NULL
v65536 mediumtext NO NULL
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
#----------------------------------
# VARCHAR(64) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARCHAR(64) NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varchar(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test default');
SELECT HEX(c) FROM t1;
HEX(c)
746573742064656661756C74
DROP TABLE t1;
#----------------------------------
# VARCHAR(64) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c VARCHAR(64) NOT NULL DEFAULT 'test default'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varchar(64) NO test default
ALTER TABLE t1 ADD COLUMN err VARCHAR(64) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test default');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 746573742064656661756C74
2 746573742064656661756C74
DROP TABLE t1;
########################
# date and time columns
########################
set @col_opt_not_nullsave_time_zone=@@time_zone;
set time_zone='UTC';
DROP TABLE IF EXISTS t1;
set @save_time_zone=@@time_zone;
set time_zone='UTC';
CREATE TABLE t1 (
d DATE NOT NULL,
dt DATETIME NOT NULL,
ts TIMESTAMP NOT NULL,
t TIME NOT NULL,
y YEAR NOT NULL,
y4 YEAR(4) NOT NULL,
y2 YEAR(2) NOT NULL,
pk DATETIME PRIMARY KEY
) ENGINE=rocksdb;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date NO NULL
dt datetime NO NULL
ts timestamp NO NULL
t time NO NULL
y year(4) NO NULL
y4 year(4) NO NULL
y2 year(2) NO NULL
pk datetime NO PRI NULL
SET @tm = '2012-04-09 05:27:00';
INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
d dt ts t y y4 y2
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
Warning 1265 Data truncated for column 'dt' at row 1
Warning 1265 Data truncated for column 'ts' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 'y' at row 1
Warning 1264 Out of range value for column 'y4' at row 1
Warning 1264 Out of range value for column 'y2' at row 1
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
d dt ts t y y4 y2
1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
set time_zone=@save_time_zone;
DROP TABLE t1;
SET TIMESTAMP=UNIX_TIMESTAMP('2013-12-12 12:12:12');
DROP TABLE IF EXISTS t1;
#----------------------------------
# DATE NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATE NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c date NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21');
SELECT HEX(c) FROM t1;
HEX(c)
323031322D31322D3231
DROP TABLE t1;
#----------------------------------
# DATE NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DATE NOT NULL DEFAULT '2012-12-21'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c date NO 2012-12-21
ALTER TABLE t1 ADD COLUMN err DATE NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031322D31322D3231
2 323031322D31322D3231
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DATETIME NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATETIME NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c datetime NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
323031322D31322D32312031323A32313A3132
DROP TABLE t1;
#----------------------------------
# DATETIME NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DATETIME NOT NULL DEFAULT '2012-12-21 12:21:12'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c datetime NO 2012-12-21 12:21:12
ALTER TABLE t1 ADD COLUMN err DATETIME NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031322D31322D32312031323A32313A3132
2 323031322D31322D32312031323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TIMESTAMP NOT NULL column without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIMESTAMP NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c timestamp NO NULL
INSERT INTO t1 (c) VALUES (NULL);
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
323031332D31322D31322031323A31323A3132
323031322D31322D32312031323A32313A3132
DROP TABLE t1;
#----------------------------------
# TIMESTAMP NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TIMESTAMP NOT NULL DEFAULT '2012-12-21 12:21:12'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c timestamp NO 2012-12-21 12:21:12
ALTER TABLE t1 ADD COLUMN err TIMESTAMP NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
set @save_ts=@@timestamp;
set timestamp=1478923914;
INSERT INTO t1 (c) VALUES (NULL);
set timestamp=@save_ts;
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031362D31312D31322030343A31313A3534
2 323031322D31322D32312031323A32313A3132
3 323031322D31322D32312031323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TIME NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIME NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c time NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
31323A32313A3132
DROP TABLE t1;
#----------------------------------
# TIME NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TIME NOT NULL DEFAULT '12:21:12'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c time NO 12:21:12
ALTER TABLE t1 ADD COLUMN err TIME NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 31323A32313A3132
2 31323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# YEAR NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012');
SELECT HEX(c) FROM t1;
HEX(c)
7DC
DROP TABLE t1;
#----------------------------------
# YEAR NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c YEAR NOT NULL DEFAULT '2012'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO 2012
ALTER TABLE t1 ADD COLUMN err YEAR NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7DC
2 7DC
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# YEAR(2) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR(2) NOT NULL) ENGINE=rocksdb;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(2) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12');
SELECT HEX(c) FROM t1;
HEX(c)
C
DROP TABLE t1;
#----------------------------------
# YEAR(2) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c YEAR(2) NOT NULL DEFAULT '12'
) ENGINE=rocksdb;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(2) NO 12
ALTER TABLE t1 ADD COLUMN err YEAR(2) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 C
2 C
DROP TABLE t1;
set time_zone= @col_opt_not_nullsave_time_zone;
########################
# ENUM columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a ENUM('') NOT NULL,
b ENUM('test1','test2','test3','test4','test5') NOT NULL,
c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NOT NULL,
PRIMARY KEY (b)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a enum('') NO NULL
b enum('test1','test2','test3','test4','test5') NO PRI NULL
c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
SELECT a,b,c FROM t1;
a b c
test2 4
test5 2
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
test2 4
test5 2
ALTER TABLE t1 ADD COLUMN e ENUM('a','A') NOT NULL;
Warnings:
Note 1291 Column 'e' has duplicated value 'a' in ENUM
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a enum('') NO NULL
b enum('test1','test2','test3','test4','test5') NO PRI NULL
c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
e enum('a','A') NO NULL
INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
SELECT a,b,c,e FROM t1;
a b c e
a
test2 4 a
test3 75 a
test5 2 a
SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
a b c e
test2 4 a
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# ENUM('test1','test2','test3') NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c ENUM('test1','test2','test3') NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c enum('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2');
SELECT HEX(c) FROM t1;
HEX(c)
7465737432
DROP TABLE t1;
#----------------------------------
# ENUM('test1','test2','test3') NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c ENUM('test1','test2','test3') NOT NULL DEFAULT 'test2'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c enum('test1','test2','test3') NO test2
ALTER TABLE t1 ADD COLUMN err ENUM('test1','test2','test3') NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7465737432
2 7465737432
DROP TABLE t1;
########################
# Fixed point columns (NUMERIC, DECIMAL)
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
d DECIMAL NOT NULL,
d0 DECIMAL(0) NOT NULL,
d1_1 DECIMAL(1,1) NOT NULL,
d10_2 DECIMAL(10,2) NOT NULL,
d60_10 DECIMAL(60,10) NOT NULL,
n NUMERIC NOT NULL,
n0_0 NUMERIC(0,0) NOT NULL,
n1 NUMERIC(1) NOT NULL,
n20_4 NUMERIC(20,4) NOT NULL,
n65_4 NUMERIC(65,4) NOT NULL,
pk NUMERIC NOT NULL PRIMARY KEY
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d decimal(10,0) NO NULL
d0 decimal(10,0) NO NULL
d1_1 decimal(1,1) NO NULL
d10_2 decimal(10,2) NO NULL
d60_10 decimal(60,10) NO NULL
n decimal(10,0) NO NULL
n0_0 decimal(10,0) NO NULL
n1 decimal(1,0) NO NULL
n20_4 decimal(20,4) NO NULL
n65_4 decimal(65,4) NO NULL
pk decimal(10,0) NO PRI NULL
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
6
);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
Warnings:
Note 1265 Data truncated for column 'd' at row 1
Note 1265 Data truncated for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Note 1265 Data truncated for column 'd10_2' at row 1
Note 1265 Data truncated for column 'd60_10' at row 1
Note 1265 Data truncated for column 'n' at row 1
Note 1265 Data truncated for column 'n0_0' at row 1
Note 1265 Data truncated for column 'n1' at row 1
Note 1265 Data truncated for column 'n20_4' at row 1
Note 1265 Data truncated for column 'n65_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NOT NULL;
ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NOT NULL;
ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NOT NULL;
ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DECIMAL NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DECIMAL NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# DECIMAL NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DECIMAL NOT NULL DEFAULT 1.1
) ENGINE=rocksdb;
Warnings:
Note 1265 Data truncated for column 'c' at row 1
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO 1
ALTER TABLE t1 ADD COLUMN err DECIMAL NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# NUMERIC NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c NUMERIC NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# NUMERIC NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c NUMERIC NOT NULL DEFAULT 0
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO 0
ALTER TABLE t1 ADD COLUMN err NUMERIC NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# Floating point columns (FLOAT, DOUBLE)
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
f FLOAT NOT NULL,
f0 FLOAT(0) NOT NULL,
r1_1 REAL(1,1) NOT NULL,
f23_0 FLOAT(23) NOT NULL,
f20_3 FLOAT(20,3) NOT NULL,
d DOUBLE NOT NULL,
d1_0 DOUBLE(1,0) NOT NULL,
d10_10 DOUBLE PRECISION (10,10) NOT NULL,
d53 DOUBLE(53,0) NOT NULL,
d53_10 DOUBLE(53,10) NOT NULL,
pk DOUBLE NOT NULL PRIMARY KEY
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
f float NO NULL
f0 float NO NULL
r1_1 double(1,1) NO NULL
f23_0 float NO NULL
f20_3 float(20,3) NO NULL
d double NO NULL
d1_0 double(1,0) NO NULL
d10_10 double(10,10) NO NULL
d53 double(53,0) NO NULL
d53_10 double(53,10) NO NULL
pk double NO PRI NULL
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d 11111111.111
d10_10 0.0123456789
d1_0 8
d53 1234566789123456800
d53_10 100000000000000000.0000000000
f0 12345.1
f20_3 56789.988
f23_0 123457000
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
99999999999999999999999999999999999999,
99999999999999999999999999999999999999.9999999999999999,
0.9,
99999999999999999999999999999999999999.9,
99999999999999999.999,
999999999999999999999999999999999999999999999999999999999999999999999999999999999,
9,
0.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999,
3
);
Warnings:
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d 0
d 11111111.111
d 1e81
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 8
d1_0 9
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 1e38
f0 0
f0 12345.1
f0 1e38
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 0.0
r1_1 0.9
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
MAX(f) 9.999999680285692e37
MAX(d) 1e81
MAX(d10_10) 0.9999999999
MAX(d1_0) 9
MAX(d53) 100000000000000000000000000000000000000000000000000000
MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
MAX(f0) 9.999999680285692e37
MAX(f20_3) 99999998430674940.000
MAX(f23_0) 9.999999680285692e37
MAX(r1_1) 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
5
);
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e61
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f 3.40282e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
999999999999999999999999999999999999999,
999999999999999999999999999999999999999.9999999999999999,
1.9,
999999999999999999999999999999999999999.9,
999999999999999999.999,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
99,
1.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999,
6
);
Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e61
d 1e65
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f 3.40282e38
f 3.40282e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f0 3.40282e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
f23_0 3.40282e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
r1_1 0.9
ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NOT NULL;
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NOT NULL;
ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NOT NULL;
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# FLOAT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c FLOAT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c float NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# FLOAT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c FLOAT NOT NULL DEFAULT 1.1
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c float NO 1.1
ALTER TABLE t1 ADD COLUMN err FLOAT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DOUBLE NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DOUBLE NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c double NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# DOUBLE NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DOUBLE NOT NULL DEFAULT 0
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c double NO 0
ALTER TABLE t1 ADD COLUMN err DOUBLE NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# INT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
i INT NOT NULL,
i0 INT(0) NOT NULL,
i1 INT(1) NOT NULL,
i20 INT(20) NOT NULL,
t TINYINT NOT NULL,
t0 TINYINT(0) NOT NULL,
t1 TINYINT(1) NOT NULL,
t20 TINYINT(20) NOT NULL,
s SMALLINT NOT NULL,
s0 SMALLINT(0) NOT NULL,
s1 SMALLINT(1) NOT NULL,
s20 SMALLINT(20) NOT NULL,
m MEDIUMINT NOT NULL,
m0 MEDIUMINT(0) NOT NULL,
m1 MEDIUMINT(1) NOT NULL,
m20 MEDIUMINT(20) NOT NULL,
b BIGINT NOT NULL,
b0 BIGINT(0) NOT NULL,
b1 BIGINT(1) NOT NULL,
b20 BIGINT(20) NOT NULL,
pk INT AUTO_INCREMENT PRIMARY KEY
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
i int(11) NO NULL
i0 int(11) NO NULL
i1 int(1) NO NULL
i20 int(20) NO NULL
t tinyint(4) NO NULL
t0 tinyint(4) NO NULL
t1 tinyint(1) NO NULL
t20 tinyint(20) NO NULL
s smallint(6) NO NULL
s0 smallint(6) NO NULL
s1 smallint(1) NO NULL
s20 smallint(20) NO NULL
m mediumint(9) NO NULL
m0 mediumint(9) NO NULL
m1 mediumint(1) NO NULL
m20 mediumint(20) NO NULL
b bigint(20) NO NULL
b0 bigint(20) NO NULL
b1 bigint(1) NO NULL
b20 bigint(20) NO NULL
pk int(11) NO PRI NULL auto_increment
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 8
Warning 1264 Out of range value for column 'i0' at row 8
Warning 1264 Out of range value for column 'i1' at row 8
Warning 1264 Out of range value for column 'i20' at row 8
Warning 1264 Out of range value for column 't' at row 8
Warning 1264 Out of range value for column 't0' at row 8
Warning 1264 Out of range value for column 't1' at row 8
Warning 1264 Out of range value for column 't20' at row 8
Warning 1264 Out of range value for column 's' at row 8
Warning 1264 Out of range value for column 's0' at row 8
Warning 1264 Out of range value for column 's1' at row 8
Warning 1264 Out of range value for column 's20' at row 8
Warning 1264 Out of range value for column 'm' at row 8
Warning 1264 Out of range value for column 'm0' at row 8
Warning 1264 Out of range value for column 'm1' at row 8
Warning 1264 Out of range value for column 'm20' at row 8
Warning 1264 Out of range value for column 'i' at row 9
Warning 1264 Out of range value for column 'i0' at row 9
Warning 1264 Out of range value for column 'i1' at row 9
Warning 1264 Out of range value for column 'i20' at row 9
Warning 1264 Out of range value for column 't' at row 9
Warning 1264 Out of range value for column 't0' at row 9
Warning 1264 Out of range value for column 't1' at row 9
Warning 1264 Out of range value for column 't20' at row 9
Warning 1264 Out of range value for column 's' at row 9
Warning 1264 Out of range value for column 's0' at row 9
Warning 1264 Out of range value for column 's1' at row 9
Warning 1264 Out of range value for column 's20' at row 9
Warning 1264 Out of range value for column 'm' at row 9
Warning 1264 Out of range value for column 'm0' at row 9
Warning 1264 Out of range value for column 'm1' at row 9
Warning 1264 Out of range value for column 'm20' at row 9
Warning 1264 Out of range value for column 'i' at row 10
Warning 1264 Out of range value for column 'i0' at row 10
Warning 1264 Out of range value for column 'i1' at row 10
Warning 1264 Out of range value for column 'i20' at row 10
Warning 1264 Out of range value for column 't' at row 10
Warning 1264 Out of range value for column 't0' at row 10
Warning 1264 Out of range value for column 't1' at row 10
Warning 1264 Out of range value for column 't20' at row 10
Warning 1264 Out of range value for column 's' at row 10
Warning 1264 Out of range value for column 's0' at row 10
Warning 1264 Out of range value for column 's1' at row 10
Warning 1264 Out of range value for column 's20' at row 10
Warning 1264 Out of range value for column 'm' at row 10
Warning 1264 Out of range value for column 'm0' at row 10
Warning 1264 Out of range value for column 'm1' at row 10
Warning 1264 Out of range value for column 'm20' at row 10
Warning 1264 Out of range value for column 'i' at row 11
Warning 1264 Out of range value for column 'i0' at row 11
Warning 1264 Out of range value for column 'i1' at row 11
Warning 1264 Out of range value for column 'i20' at row 11
Warning 1264 Out of range value for column 't' at row 11
Warning 1264 Out of range value for column 't0' at row 11
Warning 1264 Out of range value for column 't1' at row 11
Warning 1264 Out of range value for column 't20' at row 11
Warning 1264 Out of range value for column 's' at row 11
Warning 1264 Out of range value for column 's0' at row 11
Warning 1264 Out of range value for column 's1' at row 11
Warning 1264 Out of range value for column 's20' at row 11
Warning 1264 Out of range value for column 'm' at row 11
Warning 1264 Out of range value for column 'm0' at row 11
Warning 1264 Out of range value for column 'm1' at row 11
Warning 1264 Out of range value for column 'm20' at row 11
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
ALTER TABLE t1 ADD COLUMN i257 INT(257) NOT NULL;
ERROR 42000: Display width out of range for 'i257' (max = 255)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# INT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c INT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c int(11) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (2147483647);
SELECT HEX(c) FROM t1;
HEX(c)
7FFFFFFF
DROP TABLE t1;
#----------------------------------
# INT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c INT NOT NULL DEFAULT 2147483647
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c int(11) NO 2147483647
ALTER TABLE t1 ADD COLUMN err INT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (2147483647);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7FFFFFFF
2 7FFFFFFF
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYINT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (127);
SELECT HEX(c) FROM t1;
HEX(c)
7F
DROP TABLE t1;
#----------------------------------
# TINYINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYINT NOT NULL DEFAULT 127
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(4) NO 127
ALTER TABLE t1 ADD COLUMN err TINYINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (127);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7F
2 7F
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# SMALLINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SMALLINT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c smallint(6) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# SMALLINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c SMALLINT NOT NULL DEFAULT 0
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c smallint(6) NO 0
ALTER TABLE t1 ADD COLUMN err SMALLINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMINT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumint(9) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# MEDIUMINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMINT NOT NULL DEFAULT 1
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumint(9) NO 1
ALTER TABLE t1 ADD COLUMN err MEDIUMINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BIGINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIGINT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bigint(20) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (9223372036854775807);
SELECT HEX(c) FROM t1;
HEX(c)
7FFFFFFFFFFFFFFF
DROP TABLE t1;
#----------------------------------
# BIGINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BIGINT NOT NULL DEFAULT 9223372036854775807
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bigint(20) NO 9223372036854775807
ALTER TABLE t1 ADD COLUMN err BIGINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (9223372036854775807);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7FFFFFFFFFFFFFFF
2 7FFFFFFFFFFFFFFF
DROP TABLE t1;
########################
# SET columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a SET('') NOT NULL,
b SET('test1','test2','test3','test4','test5') NOT NULL,
c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NOT NULL,
PRIMARY KEY (c)
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a set('') NO NULL
b set('test1','test2','test3','test4','test5') NO NULL
c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
INSERT INTO t1 (a,b,c) VALUES
('','test2,test3','01,34,44,,23'),
('',5,2),
(',','test4,test2','');
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
test1,test3 02
test2,test3 01,23,34,44
test2,test4
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50'51,52,53,54,55,56,57,58,59,60,61,62,63,64
test1,test3 02
test2,test3 01,23,34,44
test2,test4
ALTER TABLE t1 ADD COLUMN e SET('a','A') NOT NULL;
Warnings:
Note 1291 Column 'e' has duplicated value 'a' in SET
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a set('') NO NULL
b set('test1','test2','test3','test4','test5') NO NULL
c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
e set('a','A') NO NULL
ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') NOT NULL;
ERROR HY000: Too many strings for column f and SET
SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
a b c e
test2,test3 01,23,34,44
test2,test4
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# SET('test1','test2','test3') NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SET('test1','test2','test3') NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c set('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2,test3');
SELECT HEX(c) FROM t1;
HEX(c)
74657374322C7465737433
DROP TABLE t1;
#----------------------------------
# SET('test1','test2','test3') NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c SET('test1','test2','test3') NOT NULL DEFAULT 'test2,test3'
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c set('test1','test2','test3') NO test2,test3
ALTER TABLE t1 ADD COLUMN err SET('test1','test2','test3') NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2,test3');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 74657374322C7465737433
2 74657374322C7465737433
DROP TABLE t1;
########################
# TEXT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
t TEXT NOT NULL,
t0 TEXT(0) NOT NULL,
t1 TEXT(1) NOT NULL,
t300 TEXT(300) NOT NULL,
tm TEXT(65535) NOT NULL,
t70k TEXT(70000) NOT NULL,
t17m TEXT(17000000) NOT NULL,
tt TINYTEXT NOT NULL,
m MEDIUMTEXT NOT NULL,
l LONGTEXT NOT NULL
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
t text NO NULL
t0 text NO NULL
t1 tinytext NO NULL
t300 text NO NULL
tm text NO NULL
t70k mediumtext NO NULL
t17m longtext NO NULL
tt tinytext NO NULL
m mediumtext NO NULL
l longtext NO NULL
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
('','','','','','','','','',''),
('a','b','c','d','e','f','g','h','i','j'),
('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5 6
65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
Warnings:
Warning 1265 Data truncated for column 't' at row 1
Warning 1265 Data truncated for column 't0' at row 1
Warning 1265 Data truncated for column 't1' at row 1
Warning 1265 Data truncated for column 't300' at row 1
Warning 1265 Data truncated for column 'tm' at row 1
Warning 1265 Data truncated for column 'tt' at row 1
SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5 6
65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) NOT NULL;
ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TEXT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c text NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TEXT NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c text NO ''
ALTER TABLE t1 ADD COLUMN err TEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYTEXT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinytext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TINYTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYTEXT NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinytext NO ''
ALTER TABLE t1 ADD COLUMN err TINYTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMTEXT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# MEDIUMTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMTEXT NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumtext NO ''
ALTER TABLE t1 ADD COLUMN err MEDIUMTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# LONGTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGTEXT NOT NULL) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# LONGTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c LONGTEXT NOT NULL DEFAULT ''
) ENGINE=rocksdb;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longtext NO ''
ALTER TABLE t1 ADD COLUMN err LONGTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
|