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
|
#
# BINARY columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS> NOT NULL,
b0 BINARY(0) <CUSTOM_COL_OPTIONS> NOT NULL,
b1 BINARY(1) <CUSTOM_COL_OPTIONS> NOT NULL,
b20 BINARY(20) <CUSTOM_COL_OPTIONS> NOT NULL,
b255 BINARY(255) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b binary(1) # # # #
b0 binary(0) # # # #
b1 binary(1) # # # #
b20 binary(20) # # # #
b255 binary(255) # # # #
INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('','','','','');
INSERT INTO t1 (b,b0,b1,b20,b255) 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 HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
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 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
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
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'b0' at row 2
Warning 1265 Data truncated for column 'b1' at row 2
Warning 1265 Data truncated for column 'b20' at row 2
Warning 1265 Data truncated for column 'b255' at row 2
Warning 1265 Data truncated for column 'b' at row 3
Warning 1265 Data truncated for column 'b0' at row 3
Warning 1265 Data truncated for column 'b1' at row 3
Warning 1265 Data truncated for column 'b20' at row 3
Warning 1265 Data truncated for column 'b255' at row 3
SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
43 43 4372656174696E6720616E2061727469636C6520 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
78 78 7878787878787878787878787878787878787878 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
ALTER TABLE t1 ADD COLUMN b257 BINARY(257) <CUSTOM_COL_OPTIONS> 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) # # # #
b0 binary(0) # # # #
b1 binary(1) # # # #
b20 binary(20) # # # #
b255 binary(255) # # # #
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c binary(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NOT NULL,
c2 BINARY <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c binary(1) NO NULL
c2 binary(1) NO 0
ALTER TABLE t1 ADD COLUMN err BINARY <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# VARBINARY columns
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (v0 VARBINARY(0) <CUSTOM_COL_OPTIONS> NOT NULL,
v1 VARBINARY(1) <CUSTOM_COL_OPTIONS> NOT NULL,
v64 VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL,
v65000 VARBINARY(65000) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varbinary(0) # # #
v1 varbinary(1) # # #
v64 varbinary(64) # # #
v65000 varbinary(65000) # # #
CREATE TABLE t2 (v VARBINARY(65532) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v varbinary(65532) # # #
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, v65000, CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 2
Warning 1265 Data truncated for column 'v1' at row 2
Warning 1265 Data truncated for column 'v64' at row 2
Warning 1265 Data truncated for column 'v0' at row 3
Warning 1265 Data truncated for column 'v1' at row 3
Warning 1265 Data truncated for column 'v64' at row 3
Warning 1265 Data truncated for column 'v65000' at row 3
SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
0
0
48 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E20576527766520 5932
61 61626364656667686920616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364 130000
79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) <CUSTOM_COL_OPTIONS> 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) # # #
v1 varbinary(1) # # #
v64 varbinary(64) # # #
v65000 varbinary(65000) # # #
v65536 mediumblob # # #
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varbinary(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL,
c2 VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varbinary(64) NO NULL
c2 varbinary(64) NO test
ALTER TABLE t1 ADD COLUMN err VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('test');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# BIT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS> NOT NULL,
b BIT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
c BIT(64) <CUSTOM_COL_OPTIONS> NOT NULL,
d BIT(1) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) # # #
b bit(20) # # #
c bit(64) # # #
d bit(1) # # #
ALTER TABLE t1 DROP COLUMN d;
ALTER TABLE t1 ADD COLUMN d BIT(0) <CUSTOM_COL_OPTIONS> NOT NULL;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) # # #
b bit(20) # # #
c bit(64) # # #
d bit(1) # # #
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,-1,0);
SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
a+0 b+0 c+0
0 1048575 18446744073709551615
1 0 18446744073709551615
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 18446744073709551615
1 102 255
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,b,c,d FROM t1;
a b c d
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,b,c,d FROM t1;
a b c d
DROP TABLE t1;
CREATE TABLE t1 (a BIT(65) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ERROR 42000: Display width out of range for 'a' (max = 64)
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bit(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 BIT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bit(1) NO NULL
c2 bit(1) NO b'1'
ALTER TABLE t1 ADD COLUMN err BIT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# BLOB columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS> NOT NULL,
b0 BLOB(0) <CUSTOM_COL_OPTIONS> NOT NULL,
b1 BLOB(1) <CUSTOM_COL_OPTIONS> NOT NULL,
b300 BLOB(300) <CUSTOM_COL_OPTIONS> NOT NULL,
bm BLOB(65535) <CUSTOM_COL_OPTIONS> NOT NULL,
b70k BLOB(70000) <CUSTOM_COL_OPTIONS> NOT NULL,
b17m BLOB(17000000) <CUSTOM_COL_OPTIONS> NOT NULL,
t TINYBLOB <CUSTOM_COL_OPTIONS> NOT NULL,
m MEDIUMBLOB <CUSTOM_COL_OPTIONS> NOT NULL,
l LONGBLOB <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b blob # # #
b0 blob # # #
b1 tinyblob # # #
b300 blob # # #
bm blob # # #
b70k mediumblob # # #
b17m longblob # # #
t tinyblob # # #
m mediumblob # # #
l longblob # # #
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;
CREATE TABLE t1 (c BLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c blob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c LONGBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c longblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
#
# BOOL columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b1 BOOL <CUSTOM_COL_OPTIONS> NOT NULL,
b2 BOOLEAN <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b1 tinyint(1) # # #
b2 tinyint(1) # # #
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;
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' at line 1
ALTER TABLE t1 ADD COLUMN b3 BOOL ZEROFILL;
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 'ZEROFILL' at line 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NOT NULL,
c2 BOOL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '0'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(1) NO NULL
c2 tinyint(1) NO 0
ALTER TABLE t1 ADD COLUMN err BOOL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('0');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# CHAR columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL,
c0 CHAR(0) <CUSTOM_COL_OPTIONS> NOT NULL,
c1 CHAR(1) <CUSTOM_COL_OPTIONS> NOT NULL,
c20 CHAR(20) <CUSTOM_COL_OPTIONS> NOT NULL,
c255 CHAR(255) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) # # #
c0 char(0) # # #
c1 char(1) # # #
c20 char(20) # # #
c255 char(255) # # #
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(c255,c1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'c' at row 2
Warning 1265 Data truncated for column 'c0' at row 2
Warning 1265 Data truncated for column 'c1' at row 2
Warning 1265 Data truncated for column 'c20' at row 2
Warning 1265 Data truncated for column 'c' at row 3
Warning 1265 Data truncated for column 'c0' at row 3
Warning 1265 Data truncated for column 'c1' at row 3
Warning 1265 Data truncated for column 'c20' at row 3
Warning 1265 Data truncated for column 'c255' at row 3
SELECT c,c0,c1,c20,c255 FROM t1;
c c0 c1 c20 c255
C C Creating an article 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.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 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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) <CUSTOM_COL_OPTIONS> 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;
CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL,
c2 CHAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '_'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) NO NULL
c2 char(1) NO _
ALTER TABLE t1 ADD COLUMN err CHAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('_');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# VARCHAR columns
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (v0 VARCHAR(0) <CUSTOM_COL_OPTIONS> NOT NULL,
v1 VARCHAR(1) <CUSTOM_COL_OPTIONS> NOT NULL,
v64 VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL,
v65000 VARCHAR(65000) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varchar(0) # # #
v1 varchar(1) # # #
v64 varchar(64) # # #
v65000 varchar(65000) # # #
CREATE TABLE t2 (v VARCHAR(65532) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v varchar(65532) # # #
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, v65000, CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 2
Warning 1265 Data truncated for column 'v1' at row 2
Warning 1265 Data truncated for column 'v64' at row 2
Warning 1265 Data truncated for column 'v0' at row 3
Warning 1265 Data truncated for column 'v1' at row 3
Warning 1265 Data truncated for column 'v64' at row 3
Warning 1265 Data truncated for column 'v65000' at row 3
SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
v0 v1 v64 LENGTH(v65000)
0
0
H Here is a list of recommended books on MariaDB and MySQL. We've 2966
a abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcd 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) <CUSTOM_COL_OPTIONS> 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) # # #
v1 varchar(1) # # #
v64 varchar(64) # # #
v65000 varchar(65000) # # #
v65536 mediumtext # # #
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varchar(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL,
c2 VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test default'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varchar(64) NO NULL
c2 varchar(64) NO test default
ALTER TABLE t1 ADD COLUMN err VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('test default');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# date and time columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS> NOT NULL,
dt DATETIME <CUSTOM_COL_OPTIONS> NOT NULL,
ts TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL,
t TIME <CUSTOM_COL_OPTIONS> NOT NULL,
y YEAR <CUSTOM_COL_OPTIONS> NOT NULL,
y4 YEAR(4) <CUSTOM_COL_OPTIONS> NOT NULL,
y2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
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 # # #
dt datetime # # #
ts timestamp # # # on update CURRENT_TIMESTAMP
t time # # #
y year(4) # # #
y4 year(4) # # #
y2 year(2) # # #
SET @tm = '2012-04-09 05:27:00';
INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm));
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) VALUES
('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );
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
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
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
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c date NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NOT NULL,
c2 DATE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-12-21'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c date NO NULL
c2 date NO 2012-12-21
ALTER TABLE t1 ADD COLUMN err DATE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c datetime NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NOT NULL,
c2 DATETIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-12-21 12:21:12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c datetime NO NULL
c2 datetime NO 2012-12-21 12:21:12
ALTER TABLE t1 ADD COLUMN err DATETIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL,
c2 TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-02-21 12:21:12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
ALTER TABLE t1 ADD COLUMN err TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
INSERT INTO t1 (c2) VALUES (NULL);
SELECT c, c2 FROM t1;
c c2
<TIMESTAMP> <DEFAULT_TIMESTAMP>
<TIMESTAMP> <TIMESTAMP>
DROP TABLE t1;
CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
INSERT INTO t1 (c) VALUES (NULL);
SELECT c FROM t1;
c
<TIMESTAMP>
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c time NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NOT NULL,
c2 TIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '12:21:12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c time NO NULL
c2 time NO 12:21:12
ALTER TABLE t1 ADD COLUMN err TIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('12:21:12');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NOT NULL,
c2 YEAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(4) NO NULL
c2 year(4) NO 2012
ALTER TABLE t1 ADD COLUMN err YEAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('2012');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
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
c year(2) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL,
c2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
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
c year(2) NO NULL
c2 year(2) NO 12
ALTER TABLE t1 ADD COLUMN err YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('12');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# ENUM columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a ENUM('') <CUSTOM_COL_OPTIONS> NOT NULL,
b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> 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') <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a enum('') # # #
b enum('test1','test2','test3','test4','test5') # # #
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') # # #
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') <CUSTOM_COL_OPTIONS> 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('') # # #
b enum('test1','test2','test3','test4','test5') # # #
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') # # #
e enum('a','A') # # #
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;
CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c enum('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL,
c2 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test2'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c enum('test1','test2','test3') NO NULL
c2 enum('test1','test2','test3') NO test2
ALTER TABLE t1 ADD COLUMN err ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('test2');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# Fixed point columns (NUMERIC, DECIMAL)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL,
d0 DECIMAL(0) <CUSTOM_COL_OPTIONS> NOT NULL,
d1_1 DECIMAL(1,1) <CUSTOM_COL_OPTIONS> NOT NULL,
d10_2 DECIMAL(10,2) <CUSTOM_COL_OPTIONS> NOT NULL,
d60_10 DECIMAL(60,10) <CUSTOM_COL_OPTIONS> NOT NULL,
n NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL,
n0_0 NUMERIC(0,0) <CUSTOM_COL_OPTIONS> NOT NULL,
n1 NUMERIC(1) <CUSTOM_COL_OPTIONS> NOT NULL,
n20_4 NUMERIC(20,4) <CUSTOM_COL_OPTIONS> NOT NULL,
n65_4 NUMERIC(65,4) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d decimal(10,0) # # #
d0 decimal(10,0) # # #
d1_1 decimal(1,1) # # #
d10_2 decimal(10,2) # # #
d60_10 decimal(60,10) # # #
n decimal(10,0) # # #
n0_0 decimal(10,0) # # #
n1 decimal(1,0) # # #
n20_4 decimal(20,4) # # #
n65_4 decimal(65,4) # # #
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
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) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
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) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
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) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
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) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
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);
ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL,
c2 DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1.1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
Warnings:
Note 1265 Data truncated for column 'c2' at row 1
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) NO NULL
c2 decimal(10,0) NO 1
ALTER TABLE t1 ADD COLUMN err DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL,
c2 NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) NO NULL
c2 decimal(10,0) NO 0
ALTER TABLE t1 ADD COLUMN err NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# Floating point columns (FLOAT, DOUBLE)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS> NOT NULL,
f0 FLOAT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
r1_1 REAL(1,1) <CUSTOM_COL_OPTIONS> NOT NULL,
f23_0 FLOAT(23) <CUSTOM_COL_OPTIONS> NOT NULL,
f20_3 FLOAT(20,3) <CUSTOM_COL_OPTIONS> NOT NULL,
d DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL,
d1_0 DOUBLE(1,0) <CUSTOM_COL_OPTIONS> NOT NULL,
d10_10 DOUBLE PRECISION (10,10) <CUSTOM_COL_OPTIONS> NOT NULL,
d53 DOUBLE(53,0) <CUSTOM_COL_OPTIONS> NOT NULL,
d53_10 DOUBLE(53,10) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
f float # # #
f0 float # # #
r1_1 double(1,1) # # #
f23_0 float # # #
f20_3 float(20,3) # # #
d double # # #
d1_0 double(1,0) # # #
d10_10 double(10,10) # # #
d53 double(53,0) # # #
d53_10 double(53,10) # # #
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
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) VALUES (0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
99999999999999999999999999999999999999,
99999999999999999999999999999999999999.9999999999999999,
0.9,
99999999999999999999999999999999999999.9,
99999999999999999.999,
999999999999999999999999999999999999999999999999999999999999999999999999999999999,
9,
0.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
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) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
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) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
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
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 1e43
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 10000000000000000000000000000000000000000000.0000000000
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 10000000000000000000000000000000000000000000
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) VALUES (
999999999999999999999999999999999999999,
999999999999999999999999999999999999999.9999999999999999,
1.9,
999999999999999999999999999999999999999.9,
999999999999999999.999,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
99,
1.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999
);
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 1e43
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 10000000000000000000000000000000000000000000.0000000000
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 10000000000000000000000000000000000000000000
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);
# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
# ------------ UNEXPECTED RESULT ------------
# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
# The statement|command succeeded unexpectedly.
# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
# Also, this problem may cause a chain effect (more errors of different kinds in the test).
# -------------------------------------------
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c float NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 FLOAT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1.1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c float NO NULL
c2 float NO 1.1
ALTER TABLE t1 ADD COLUMN err FLOAT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (1.1 );
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c double NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL,
c2 DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c double NO NULL
c2 double NO 0
ALTER TABLE t1 ADD COLUMN err DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# INT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS> NOT NULL,
i0 INT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
i1 INT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
i20 INT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
t TINYINT <CUSTOM_COL_OPTIONS> NOT NULL,
t0 TINYINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
t1 TINYINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
t20 TINYINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
s SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL,
s0 SMALLINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
s1 SMALLINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
s20 SMALLINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
m MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL,
m0 MEDIUMINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
m1 MEDIUMINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
m20 MEDIUMINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
b BIGINT <CUSTOM_COL_OPTIONS> NOT NULL,
b0 BIGINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
b1 BIGINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
b20 BIGINT(20) <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
i int(11) # # #
i0 int(11) # # #
i1 int(1) # # #
i20 int(20) # # #
t tinyint(4) # # #
t0 tinyint(4) # # #
t1 tinyint(1) # # #
t20 tinyint(20) # # #
s smallint(6) # # #
s0 smallint(6) # # #
s1 smallint(1) # # #
s20 smallint(20) # # #
m mediumint(9) # # #
m0 mediumint(9) # # #
m1 mediumint(1) # # #
m20 mediumint(20) # # #
b bigint(20) # # #
b0 bigint(20) # # #
b1 bigint(1) # # #
b20 bigint(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 (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 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 'i' at row 2
Warning 1264 Out of range value for column 'i0' at row 2
Warning 1264 Out of range value for column 'i1' at row 2
Warning 1264 Out of range value for column 'i20' at row 2
Warning 1264 Out of range value for column 't' at row 2
Warning 1264 Out of range value for column 't0' at row 2
Warning 1264 Out of range value for column 't1' at row 2
Warning 1264 Out of range value for column 't20' at row 2
Warning 1264 Out of range value for column 's' at row 2
Warning 1264 Out of range value for column 's0' at row 2
Warning 1264 Out of range value for column 's1' at row 2
Warning 1264 Out of range value for column 's20' at row 2
Warning 1264 Out of range value for column 'm' at row 2
Warning 1264 Out of range value for column 'm0' at row 2
Warning 1264 Out of range value for column 'm1' at row 2
Warning 1264 Out of range value for column 'm20' at row 2
Warning 1264 Out of range value for column 'i' at row 3
Warning 1264 Out of range value for column 'i0' at row 3
Warning 1264 Out of range value for column 'i1' at row 3
Warning 1264 Out of range value for column 'i20' at row 3
Warning 1264 Out of range value for column 't' at row 3
Warning 1264 Out of range value for column 't0' at row 3
Warning 1264 Out of range value for column 't1' at row 3
Warning 1264 Out of range value for column 't20' at row 3
Warning 1264 Out of range value for column 's' at row 3
Warning 1264 Out of range value for column 's0' at row 3
Warning 1264 Out of range value for column 's1' at row 3
Warning 1264 Out of range value for column 's20' at row 3
Warning 1264 Out of range value for column 'm' at row 3
Warning 1264 Out of range value for column 'm0' at row 3
Warning 1264 Out of range value for column 'm1' at row 3
Warning 1264 Out of range value for column 'm20' at row 3
Warning 1264 Out of range value for column 'i' at row 4
Warning 1264 Out of range value for column 'i0' at row 4
Warning 1264 Out of range value for column 'i1' at row 4
Warning 1264 Out of range value for column 'i20' at row 4
Warning 1264 Out of range value for column 't' at row 4
Warning 1264 Out of range value for column 't0' at row 4
Warning 1264 Out of range value for column 't1' at row 4
Warning 1264 Out of range value for column 't20' at row 4
Warning 1264 Out of range value for column 's' at row 4
Warning 1264 Out of range value for column 's0' at row 4
Warning 1264 Out of range value for column 's1' at row 4
Warning 1264 Out of range value for column 's20' at row 4
Warning 1264 Out of range value for column 'm' at row 4
Warning 1264 Out of range value for column 'm0' at row 4
Warning 1264 Out of range value for column 'm1' at row 4
Warning 1264 Out of range value for column 'm20' at row 4
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);
ERROR 42000: Display width out of range for 'i257' (max = 255)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c int(11) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 INT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 2147483647
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c int(11) NO NULL
c2 int(11) NO 2147483647
ALTER TABLE t1 ADD COLUMN err INT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (2147483647);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 TINYINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 127
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(4) NO NULL
c2 tinyint(4) NO 127
ALTER TABLE t1 ADD COLUMN err TINYINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (127 );
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c smallint(6) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c smallint(6) NO NULL
c2 smallint(6) NO 0
ALTER TABLE t1 ADD COLUMN err SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumint(9) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumint(9) NO NULL
c2 mediumint(9) NO 1
ALTER TABLE t1 ADD COLUMN err MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bigint(20) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NOT NULL,
c2 BIGINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 9223372036854775807
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bigint(20) NO NULL
c2 bigint(20) NO 9223372036854775807
ALTER TABLE t1 ADD COLUMN err BIGINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES (9223372036854775807);
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# SET columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a SET('') <CUSTOM_COL_OPTIONS> NOT NULL,
b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> 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') <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a set('') # # #
b set('test1','test2','test3','test4','test5') # # #
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') # # #
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') <CUSTOM_COL_OPTIONS> 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('') # # #
b set('test1','test2','test3','test4','test5') # # #
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') # # #
e set('a','A') # # #
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') <CUSTOM_COL_OPTIONS> 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;
CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c set('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL,
c2 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test2,test3'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c set('test1','test2','test3') NO NULL
c2 set('test1','test2','test3') NO test2,test3
ALTER TABLE t1 ADD COLUMN err SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
SELECT HEX(c), HEX(c2) FROM t1;
HEX(c) HEX(c2)
INSERT INTO t1 (c2) VALUES (NULL);
ERROR 23000: Column 'c2' cannot be null
INSERT INTO t1 (c) VALUES ('test2,test3');
SELECT COUNT(c), COUNT(c2) FROM t1;
COUNT(c) COUNT(c2)
1 1
DROP TABLE t1;
#
# TEXT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS> NOT NULL,
t0 TEXT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
t1 TEXT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
t300 TEXT(300) <CUSTOM_COL_OPTIONS> NOT NULL,
tm TEXT(65535) <CUSTOM_COL_OPTIONS> NOT NULL,
t70k TEXT(70000) <CUSTOM_COL_OPTIONS> NOT NULL,
t17m TEXT(17000000) <CUSTOM_COL_OPTIONS> NOT NULL,
tt TINYTEXT <CUSTOM_COL_OPTIONS> NOT NULL,
m MEDIUMTEXT <CUSTOM_COL_OPTIONS> NOT NULL,
l LONGTEXT <CUSTOM_COL_OPTIONS> NOT NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
t text # # #
t0 text # # #
t1 tinytext # # #
t300 text # # #
tm text # # #
t70k mediumtext # # #
t17m longtext # # #
tt tinytext # # #
m mediumtext # # #
l longtext # # #
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);
ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c text NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinytext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c LONGTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c longtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
DROP TABLE t1;
|