2012-07-16 04:17:56 +02:00
#
# BINARY columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS> NULL,
b0 BINARY(0) <CUSTOM_COL_OPTIONS> NULL,
b1 BINARY(1) <CUSTOM_COL_OPTIONS> NULL,
b20 BINARY(20) <CUSTOM_COL_OPTIONS> NULL,
b255 BINARY(255) <CUSTOM_COL_OPTIONS> 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) # # # #
2013-02-02 23:53:57 +01:00
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.');
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
2012-07-16 04:17:56 +02:00
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> 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c binary(1) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NULL,
c1 BINARY <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 BINARY <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c binary(1) YES NULL
c1 binary(1) YES NULL
c2 binary(1) YES 0
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# VARBINARY columns
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (v0 VARBINARY(0) <CUSTOM_COL_OPTIONS> NULL,
v1 VARBINARY(1) <CUSTOM_COL_OPTIONS> NULL,
v64 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL,
v65000 VARBINARY(65000) <CUSTOM_COL_OPTIONS> 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> 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 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E69746976652067756964652074
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> 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varbinary(64) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL,
c1 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varbinary(64) YES NULL
c1 varbinary(64) YES NULL
c2 varbinary(64) YES test
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# BIT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS> NULL,
b BIT(20) <CUSTOM_COL_OPTIONS> NULL,
c BIT(64) <CUSTOM_COL_OPTIONS> NULL,
d BIT(1) <CUSTOM_COL_OPTIONS> 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> NULL;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) # # #
b bit(20) # # #
c bit(64) # # #
d bit(1) # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
2012-07-16 04:17:56 +02:00
SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
BIN(a) HEX(b) c+0
0 FFFFF 18446744073709551615
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,d) VALUES (1,0,-1,0);
2012-07-16 04:17:56 +02:00
SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
a+0 b+0 c+0
0 1048575 18446744073709551615
1 0 18446744073709551615
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
2012-07-16 04:17:56 +02:00
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
2013-02-02 23:53:57 +01:00
SELECT a,b,c,d FROM t1;
2012-07-16 04:17:56 +02:00
a b c d
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
2012-07-16 04:17:56 +02:00
Warnings:
Warning 1264 Out of range value for column 'c' at row 1
2013-02-02 23:53:57 +01:00
SELECT a,b,c,d FROM t1;
2012-07-16 04:17:56 +02:00
a b c d
DROP TABLE t1;
CREATE TABLE t1 (a BIT(65) <CUSTOM_COL_OPTIONS> 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bit(1) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NULL,
c1 BIT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 BIT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bit(1) YES NULL
c1 bit(1) YES NULL
c2 bit(1) YES b'1'
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# BLOB columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS> NULL,
b0 BLOB(0) <CUSTOM_COL_OPTIONS> NULL,
b1 BLOB(1) <CUSTOM_COL_OPTIONS> NULL,
b300 BLOB(300) <CUSTOM_COL_OPTIONS> NULL,
bm BLOB(65535) <CUSTOM_COL_OPTIONS> NULL,
b70k BLOB(70000) <CUSTOM_COL_OPTIONS> NULL,
b17m BLOB(17000000) <CUSTOM_COL_OPTIONS> NULL,
t TINYBLOB <CUSTOM_COL_OPTIONS> NULL,
m MEDIUMBLOB <CUSTOM_COL_OPTIONS> NULL,
l LONGBLOB <CUSTOM_COL_OPTIONS> 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 # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
2012-07-16 04:17:56 +02:00
('','','','','','','','','',''),
('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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
2012-07-16 04:17:56 +02:00
( 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c blob YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyblob YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumblob YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c LONGBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c longblob YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
#
# BOOL columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (b1 BOOL <CUSTOM_COL_OPTIONS> NULL,
b2 BOOLEAN <CUSTOM_COL_OPTIONS> NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b1 tinyint(1) # # #
b2 tinyint(1) # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
b1 b2
1 1
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
b1 b2
0 0
1 1
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES (2,3);
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
b1 b2
0 0
1 1
2 3
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES (-1,-2);
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
2012-07-16 04:17:56 +02:00
b1 b2
1 1
2013-02-02 23:53:57 +01:00
SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
2012-07-16 04:17:56 +02:00
b1 b2
0 0
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES ('a','b');
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
b1 b2
-1 -2
0 0
0 0
1 1
2 3
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (b1,b2) VALUES (128,-129);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT b1,b2 FROM t1;
2012-07-16 04:17:56 +02:00
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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(1) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NULL,
c1 BOOL <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 BOOL <CUSTOM_COL_OPTIONS> NULL DEFAULT '0'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(1) YES NULL
c1 tinyint(1) YES NULL
c2 tinyint(1) YES 0
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# CHAR columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NULL,
c0 CHAR(0) <CUSTOM_COL_OPTIONS> NULL,
c1 CHAR(1) <CUSTOM_COL_OPTIONS> NULL,
c20 CHAR(20) <CUSTOM_COL_OPTIONS> NULL,
c255 CHAR(255) <CUSTOM_COL_OPTIONS> 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) # # #
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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.
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT(c255,c1) FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT c,c0,c1,c20,c255 FROM t1;
2012-07-16 04:17:56 +02:00
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> 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NULL,
c1 CHAR <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 CHAR <CUSTOM_COL_OPTIONS> NULL DEFAULT '_'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) YES NULL
c1 char(1) YES NULL
c2 char(1) YES _
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# VARCHAR columns
#
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (v0 VARCHAR(0) <CUSTOM_COL_OPTIONS> NULL,
v1 VARCHAR(1) <CUSTOM_COL_OPTIONS> NULL,
v64 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL,
v65000 VARCHAR(65000) <CUSTOM_COL_OPTIONS> 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> 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. ');
2013-02-02 23:53:57 +01:00
SELECT v0,v1,v64,v65000 FROM t1;
2012-07-16 04:17:56 +02:00
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> 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varchar(64) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL,
c1 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test default'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c varchar(64) YES NULL
c1 varchar(64) YES NULL
c2 varchar(64) YES test default
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# date and time columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS> NULL,
dt DATETIME <CUSTOM_COL_OPTIONS> NULL,
ts TIMESTAMP <CUSTOM_COL_OPTIONS> NULL,
t TIME <CUSTOM_COL_OPTIONS> NULL,
y YEAR <CUSTOM_COL_OPTIONS> NULL,
y4 YEAR(4) <CUSTOM_COL_OPTIONS> NULL,
y2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
2012-12-28 14:02:33 +01:00
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
2012-07-16 04:17:56 +02:00
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date # # #
dt datetime # # #
ts timestamp # # #
t time # # #
y year(4) # # #
y4 year(4) # # #
y2 year(2) # # #
SET @tm = '2012-04-09 05:27:00';
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
2012-07-16 04:17:56 +02:00
('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));
2013-02-02 23:53:57 +01:00
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-11-11 20:40:40 +01:00
1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
2012-07-16 04:17:56 +02:00
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
2013-11-11 20:40:40 +01:00
9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
2012-07-16 04:17:56 +02:00
('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
2013-02-02 23:53:57 +01:00
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-11-11 20:40:40 +01:00
1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
2012-07-16 04:17:56 +02:00
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
2013-11-11 20:40:40 +01:00
9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
2012-07-16 04:17:56 +02:00
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c date YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NULL,
c1 DATE <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 DATE <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012-12-21'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c date YES NULL
c1 date YES NULL
c2 date YES 2012-12-21
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c datetime YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NULL,
c1 DATETIME <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 DATETIME <CUSTOM_COL_OPTIONS> 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 YES NULL
c1 datetime YES NULL
c2 datetime YES 2012-12-21 12:21:12
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c timestamp YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NULL,
c1 TIMESTAMP <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 TIMESTAMP <CUSTOM_COL_OPTIONS> 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 timestamp YES NULL
c1 timestamp YES NULL
c2 timestamp YES 2012-12-21 12:21:12
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c time YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NULL,
c1 TIME <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 TIME <CUSTOM_COL_OPTIONS> NULL DEFAULT '12:21:12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c time YES NULL
c1 time YES NULL
c2 time YES 12:21:12
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(4) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NULL,
c1 YEAR <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 YEAR <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(4) YES NULL
c1 year(4) YES NULL
c2 year(4) YES 2012
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
2012-12-28 14:02:33 +01:00
Warnings:
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
2012-07-16 04:17:56 +02:00
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL,
c1 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT '12'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
2012-12-28 14:02:33 +01:00
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
Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
2012-07-16 04:17:56 +02:00
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c year(2) YES NULL
c1 year(2) YES NULL
c2 year(2) YES 12
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# ENUM columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a ENUM('') <CUSTOM_COL_OPTIONS> NULL,
b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> 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> 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') # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
SELECT a,b,c FROM t1;
2012-07-16 04:17:56 +02:00
a b c
test2 4
test5 2
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT a,b,c FROM t1;
2012-07-16 04:17:56 +02:00
a b c
test2 4
test5 2
ALTER TABLE t1 ADD COLUMN e ENUM('a','A') <CUSTOM_COL_OPTIONS> 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') # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
SELECT a,b,c,e FROM t1;
2012-07-16 04:17:56 +02:00
a b c e
NULL
test2 4 NULL
test3 75 a
test5 2 NULL
2013-02-02 23:53:57 +01:00
SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
2012-07-16 04:17:56 +02:00
a b c e
test2 4 NULL
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c enum('test1','test2','test3') YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL,
c1 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test2'
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c enum('test1','test2','test3') YES NULL
c1 enum('test1','test2','test3') YES NULL
c2 enum('test1','test2','test3') YES test2
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# Fixed point columns (NUMERIC, DECIMAL)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (d DECIMAL <CUSTOM_COL_OPTIONS> NULL,
d0 DECIMAL(0) <CUSTOM_COL_OPTIONS> NULL,
d1_1 DECIMAL(1,1) <CUSTOM_COL_OPTIONS> NULL,
d10_2 DECIMAL(10,2) <CUSTOM_COL_OPTIONS> NULL,
d60_10 DECIMAL(60,10) <CUSTOM_COL_OPTIONS> NULL,
n NUMERIC <CUSTOM_COL_OPTIONS> NULL,
n0_0 NUMERIC(0,0) <CUSTOM_COL_OPTIONS> NULL,
n1 NUMERIC(1) <CUSTOM_COL_OPTIONS> NULL,
n20_4 NUMERIC(20,4) <CUSTOM_COL_OPTIONS> NULL,
n65_4 NUMERIC(65,4) <CUSTOM_COL_OPTIONS> 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) # # #
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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 );
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
2012-07-16 04:17:56 +02:00
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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NULL,
c1 DECIMAL <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 DECIMAL <CUSTOM_COL_OPTIONS> 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) YES NULL
c1 decimal(10,0) YES NULL
c2 decimal(10,0) YES 1
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NULL,
c1 NUMERIC <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 NUMERIC <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c decimal(10,0) YES NULL
c1 decimal(10,0) YES NULL
c2 decimal(10,0) YES 0
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# Floating point columns (FLOAT, DOUBLE)
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS> NULL,
f0 FLOAT(0) <CUSTOM_COL_OPTIONS> NULL,
r1_1 REAL(1,1) <CUSTOM_COL_OPTIONS> NULL,
f23_0 FLOAT(23) <CUSTOM_COL_OPTIONS> NULL,
f20_3 FLOAT(20,3) <CUSTOM_COL_OPTIONS> NULL,
d DOUBLE <CUSTOM_COL_OPTIONS> NULL,
d1_0 DOUBLE(1,0) <CUSTOM_COL_OPTIONS> NULL,
d10_10 DOUBLE PRECISION (10,10) <CUSTOM_COL_OPTIONS> NULL,
d53 DOUBLE(53,0) <CUSTOM_COL_OPTIONS> NULL,
d53_10 DOUBLE(53,10) <CUSTOM_COL_OPTIONS> 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) # # #
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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 (
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
2012-07-16 04:17:56 +02:00
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);
2015-02-05 00:44:03 +01:00
# 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).
# -------------------------------------------
2012-07-16 04:17:56 +02:00
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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c float YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NULL,
c1 FLOAT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 FLOAT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1.1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c float YES NULL
c1 float YES NULL
c2 float YES 1.1
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c double YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NULL,
c1 DOUBLE <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 DOUBLE <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c double YES NULL
c1 double YES NULL
c2 double YES 0
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# INT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS> NULL,
i0 INT(0) <CUSTOM_COL_OPTIONS> NULL,
i1 INT(1) <CUSTOM_COL_OPTIONS> NULL,
i20 INT(20) <CUSTOM_COL_OPTIONS> NULL,
t TINYINT <CUSTOM_COL_OPTIONS> NULL,
t0 TINYINT(0) <CUSTOM_COL_OPTIONS> NULL,
t1 TINYINT(1) <CUSTOM_COL_OPTIONS> NULL,
t20 TINYINT(20) <CUSTOM_COL_OPTIONS> NULL,
s SMALLINT <CUSTOM_COL_OPTIONS> NULL,
s0 SMALLINT(0) <CUSTOM_COL_OPTIONS> NULL,
s1 SMALLINT(1) <CUSTOM_COL_OPTIONS> NULL,
s20 SMALLINT(20) <CUSTOM_COL_OPTIONS> NULL,
m MEDIUMINT <CUSTOM_COL_OPTIONS> NULL,
m0 MEDIUMINT(0) <CUSTOM_COL_OPTIONS> NULL,
m1 MEDIUMINT(1) <CUSTOM_COL_OPTIONS> NULL,
m20 MEDIUMINT(20) <CUSTOM_COL_OPTIONS> NULL,
b BIGINT <CUSTOM_COL_OPTIONS> NULL,
b0 BIGINT(0) <CUSTOM_COL_OPTIONS> NULL,
b1 BIGINT(1) <CUSTOM_COL_OPTIONS> NULL,
b20 BIGINT(20) <CUSTOM_COL_OPTIONS> 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) # # #
2013-02-02 23:53:57 +01:00
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;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
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);
2012-07-16 04:17:56 +02:00
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
2013-02-02 23:53:57 +01:00
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
2012-07-16 04:17:56 +02:00
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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c int(11) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NULL,
c1 INT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 INT <CUSTOM_COL_OPTIONS> NULL DEFAULT 2147483647
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c int(11) YES NULL
c1 int(11) YES NULL
c2 int(11) YES 2147483647
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(4) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NULL,
c1 TINYINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 TINYINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 127
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinyint(4) YES NULL
c1 tinyint(4) YES NULL
c2 tinyint(4) YES 127
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c smallint(6) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NULL,
c1 SMALLINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 SMALLINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c smallint(6) YES NULL
c1 smallint(6) YES NULL
c2 smallint(6) YES 0
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumint(9) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NULL,
c1 MEDIUMINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 MEDIUMINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumint(9) YES NULL
c1 mediumint(9) YES NULL
c2 mediumint(9) YES 1
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bigint(20) YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NULL,
c1 BIGINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 BIGINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 9223372036854775807
) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c bigint(20) YES NULL
c1 bigint(20) YES NULL
c2 bigint(20) YES 9223372036854775807
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# SET columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a SET('') <CUSTOM_COL_OPTIONS> NULL,
b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> 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> 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') # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c) VALUES
2012-07-16 04:17:56 +02:00
('','test2,test3','01,34,44,,23'),
('',5,2),
(',','test4,test2','');
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
2013-02-02 23:53:57 +01:00
SELECT a,b,c FROM t1;
2012-07-16 04:17:56 +02:00
a b c
test1,test3 02
test2,test3 01,23,34,44
test2,test4
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
2012-07-16 04:17:56 +02:00
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'c' at row 1
2013-02-02 23:53:57 +01:00
SELECT a,b,c FROM t1;
2012-07-16 04:17:56 +02:00
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> 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> NULL;
ERROR HY000: Too many strings for column f and SET
2013-02-02 23:53:57 +01:00
SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
2012-07-16 04:17:56 +02:00
a b c e
test2,test3 01,23,34,44 NULL
test2,test4 NULL
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c set('test1','test2','test3') YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL,
c1 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
c2 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> 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') YES NULL
c1 set('test1','test2','test3') YES NULL
c2 set('test1','test2','test3') YES test2,test3
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
1 0 0 1
DROP TABLE t1;
#
# TEXT columns
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS> NULL,
t0 TEXT(0) <CUSTOM_COL_OPTIONS> NULL,
t1 TEXT(1) <CUSTOM_COL_OPTIONS> NULL,
t300 TEXT(300) <CUSTOM_COL_OPTIONS> NULL,
tm TEXT(65535) <CUSTOM_COL_OPTIONS> NULL,
t70k TEXT(70000) <CUSTOM_COL_OPTIONS> NULL,
t17m TEXT(17000000) <CUSTOM_COL_OPTIONS> NULL,
tt TINYTEXT <CUSTOM_COL_OPTIONS> NULL,
m MEDIUMTEXT <CUSTOM_COL_OPTIONS> NULL,
l LONGTEXT <CUSTOM_COL_OPTIONS> 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 # # #
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
2012-07-16 04:17:56 +02:00
('','','','','','','','','',''),
('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
2013-02-02 23:53:57 +01:00
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
2012-07-16 04:17:56 +02:00
( 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> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c text YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c TINYTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c tinytext YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c MEDIUMTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c mediumtext YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c LONGTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c longtext YES NULL
INSERT INTO t1 (c) VALUES (NULL);
SELECT COUNT(c), COUNT(*) FROM t1;
COUNT(c) COUNT(*)
0 1
DROP TABLE t1;