polardbxengine/mysql-test/suite/xengine/r/col_opt_not_null.result

2651 lines
119 KiB
Plaintext

########################
# BINARY columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
b BINARY NOT NULL,
b0 BINARY(0) NOT NULL,
b1 BINARY(1) NOT NULL,
b20 BINARY(20) NOT NULL,
b255 BINARY(255) NOT NULL,
pk BINARY PRIMARY KEY
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b binary(1) NO NULL
b0 binary(0) NO NULL
b1 binary(1) NO NULL
b20 binary(20) NO NULL
b255 binary(255) NO NULL
pk binary(1) NO PRI NULL
INSERT INTO t1 VALUES ('','','','','','');
INSERT INTO t1 VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.','a');
SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
INSERT INTO t1 VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256),'b');
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b0' at row 1
Warning 1265 Data truncated for column 'b1' at row 1
Warning 1265 Data truncated for column 'b20' at row 1
Warning 1265 Data truncated for column 'b255' at row 1
INSERT INTO t1 SELECT b255, b255, b255, b255, CONCAT('a',b255,b255), 'c' FROM t1;
ERROR 23000: Duplicate entry 'c' for key 'PRIMARY'
SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255), HEX(pk) FROM t1 ORDER BY pk;
HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255) HEX(pk)
00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00
61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878 62
61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000 61
ALTER TABLE t1 ADD COLUMN b257 BINARY(257) NOT NULL;
ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
b binary(1) NO NULL
b0 binary(0) NO NULL
b1 binary(1) NO NULL
b20 binary(20) NO NULL
b255 binary(255) NO NULL
pk binary(1) NO PRI NULL
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BINARY NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BINARY NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c binary(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
30
DROP TABLE t1;
#----------------------------------
# BINARY NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BINARY NOT NULL DEFAULT 0
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c binary(1) NO 0x30
ALTER TABLE t1 ADD COLUMN err BINARY NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 30
2 30
DROP TABLE t1;
########################
# VARBINARY columns
########################
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
v0 VARBINARY(0) NOT NULL,
v1 VARBINARY(1) NOT NULL,
v64 VARBINARY(64) NOT NULL,
v65000 VARBINARY(65000) NOT NULL,
PRIMARY KEY (v64)
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varbinary(0) NO NULL
v1 varbinary(1) NO NULL
v64 varbinary(64) NO PRI NULL
v65000 varbinary(65000) NO NULL
CREATE TABLE t2 (v VARBINARY(65532) NOT NULL, PRIMARY KEY(v(255))) ENGINE=xengine;
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v varbinary(65532) NO PRI NULL
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
Warnings:
Warning 1265 Data truncated for column 'v0' at row 1
Warning 1265 Data truncated for column 'v1' at row 1
Warning 1265 Data truncated for column 'v64' at row 1
Warning 1265 Data truncated for column 'v65000' at row 1
INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 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
61 0
48 61486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E205765277665 5932
61 61616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364656667686920616263 130000
79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) NOT NULL;
Warnings:
Note 1246 Converting column 'v65536' from VARBINARY to BLOB
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varbinary(0) NO NULL
v1 varbinary(1) NO NULL
v64 varbinary(64) NO PRI NULL
v65000 varbinary(65000) NO NULL
v65536 mediumblob NO NULL
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
#----------------------------------
# VARBINARY(64) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARBINARY(64) NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varbinary(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test');
SELECT HEX(c) FROM t1;
HEX(c)
74657374
DROP TABLE t1;
#----------------------------------
# VARBINARY(64) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c VARBINARY(64) NOT NULL DEFAULT 'test'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varbinary(64) NO 0x74657374
ALTER TABLE t1 ADD COLUMN err VARBINARY(64) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 74657374
2 74657374
DROP TABLE t1;
########################
# BIT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a BIT NOT NULL,
b BIT(20) NOT NULL,
c BIT(64) NOT NULL,
d BIT(1) NOT NULL,
PRIMARY KEY (c)
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) NO NULL
b bit(20) NO NULL
c bit(64) NO PRI NULL
d bit(1) NO NULL
ALTER TABLE t1 DROP COLUMN d;
ALTER TABLE t1 ADD COLUMN d BIT(2) NOT NULL;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a bit(1) NO NULL
b bit(20) NO NULL
c bit(64) NO PRI NULL
d bit(2) NO NULL
INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
BIN(a) HEX(b) c+0
0 FFFFF 18446744073709551615
INSERT INTO t1 (a,b,c,d) VALUES (1,0,-2,0);
SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
a+0 b+0 c+0
0 1048575 18446744073709551615
1 0 18446744073709551614
INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
a+0 b+0 c+0
1 0 18446744073709551614
1 102 255
DELETE FROM t1;
INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT a+0,b+0,c+0,d+0 FROM t1;
a+0 b+0 c+0 d+0
1 0 0 1
INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
Warnings:
Warning 1264 Out of range value for column 'c' at row 1
SELECT a+0,b+0,c+0,d+0 FROM t1;
a+0 b+0 c+0 d+0
1 0 0 1
1 0 18446744073709551615 0
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, a BIT(65) NOT NULL) ENGINE=xengine;
ERROR 42000: Display width out of range for column 'a' (max = 64)
DROP TABLE IF EXISTS t1;
#----------------------------------
# BIT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bit(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# BIT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BIT NOT NULL DEFAULT 1
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bit(1) NO b'1'
ALTER TABLE t1 ADD COLUMN err BIT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
########################
# BLOB columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
b BLOB NOT NULL,
b0 BLOB(0) NOT NULL,
b1 BLOB(1) NOT NULL,
b300 BLOB(300) NOT NULL,
bm BLOB(65535) NOT NULL,
b70k BLOB(70000) NOT NULL,
b17m BLOB(17000000) NOT NULL,
t TINYBLOB NOT NULL,
m MEDIUMBLOB NOT NULL,
l LONGBLOB NOT NULL
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
b blob NO NULL
b0 tinyblob NO NULL
b1 tinyblob NO NULL
b300 blob NO NULL
bm blob NO NULL
b70k mediumblob NO NULL
b17m longblob NO NULL
t tinyblob NO NULL
m mediumblob NO NULL
l longblob NO NULL
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
('','','','','','','','','',''),
('a','b','c','d','e','f','g','h','i','j'),
('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
Warnings:
Warning 1265 Data truncated for column 'b0' at row 4
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 255 255 65535 65535 1048576 2097152 255 1048576 2097152
INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b0' at row 1
Warning 1265 Data truncated for column 'b1' at row 1
Warning 1265 Data truncated for column 'b300' at row 1
Warning 1265 Data truncated for column 'bm' at row 1
Warning 1265 Data truncated for column 't' at row 1
SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
5 5 5 5 5 5 5 5 5 6
65535 255 255 65535 65535 1048576 1048576 255 1048576 1048576
65535 255 255 65535 65535 1048576 2097152 255 1048576 2097152
ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
ERROR 42000: Display width out of range for column 'bbb' (max = 4294967295)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BLOB NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c blob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# BLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BLOB NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c blob NO NULL
ALTER TABLE t1 ADD COLUMN err BLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYBLOB NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TINYBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYBLOB NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyblob NO NULL
ALTER TABLE t1 ADD COLUMN err TINYBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMBLOB NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# MEDIUMBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMBLOB NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumblob NO NULL
ALTER TABLE t1 ADD COLUMN err MEDIUMBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# LONGBLOB NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGBLOB NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longblob NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# LONGBLOB NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c LONGBLOB NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longblob NO NULL
ALTER TABLE t1 ADD COLUMN err LONGBLOB NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
########################
# BOOL columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
b1 BOOL NOT NULL,
b2 BOOLEAN NOT NULL
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
b1 tinyint(1) NO NULL
b2 tinyint(1) NO NULL
INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
SELECT b1,b2 FROM t1;
b1 b2
1 1
INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
SELECT b1,b2 FROM t1;
b1 b2
0 0
1 1
INSERT INTO t1 (b1,b2) VALUES (2,3);
SELECT b1,b2 FROM t1;
b1 b2
0 0
1 1
2 3
INSERT INTO t1 (b1,b2) VALUES (-1,-2);
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
1 1
2 3
SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
a b
false false
true true
true true
true true
SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
b1 b2
1 1
SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
b1 b2
0 0
INSERT INTO t1 (b1,b2) VALUES ('a','b');
Warnings:
Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1
Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
0 0
1 1
2 3
INSERT INTO t1 (b1,b2) VALUES (128,-129);
Warnings:
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b2' at row 1
SELECT b1,b2 FROM t1;
b1 b2
-1 -2
0 0
0 0
1 1
127 -128
2 3
ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED NOT NULL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED NOT NULL' at line 1
ALTER TABLE ADD COLUMN b3 BOOL ZEROFILL NOT NULL;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ADD COLUMN b3 BOOL ZEROFILL NOT NULL' at line 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BOOL NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BOOL NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('0');
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# BOOL NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BOOL NOT NULL DEFAULT '0'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(1) NO 0
ALTER TABLE t1 ADD COLUMN err BOOL NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('0');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# CHAR columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
c CHAR NOT NULL,
c0 CHAR(0) NOT NULL,
c1 CHAR(1) NOT NULL,
c20 CHAR(20) NOT NULL,
c255 CHAR(255) NOT NULL,
PRIMARY KEY (c255)
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
c char(1) NO NULL
c0 char(0) NO NULL
c1 char(1) NO NULL
c20 char(20) NO NULL
c255 char(255) NO PRI NULL
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
SELECT c,c0,c1,c20,c255 FROM t1;
c c0 c1 c20 c255
a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
Warning 1265 Data truncated for column 'c0' at row 1
Warning 1265 Data truncated for column 'c1' at row 1
Warning 1265 Data truncated for column 'c20' at row 1
Warning 1265 Data truncated for column 'c255' at row 1
INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT('a',c255,c1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'c' at row 2
Warning 1265 Data truncated for column 'c0' at row 2
Warning 1265 Data truncated for column 'c1' at row 2
Warning 1265 Data truncated for column 'c20' at row 2
Warning 1265 Data truncated for column 'c' at row 3
Warning 1265 Data truncated for column 'c0' at row 3
Warning 1265 Data truncated for column 'c1' at row 3
Warning 1265 Data truncated for column 'c20' at row 3
Warning 1265 Data truncated for column 'c255' at row 3
SELECT c,c0,c1,c20,c255 FROM t1;
c c0 c1 c20 c255
a
C C Creating an article aCreating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
x x xxxxxxxxxxxxxxxxxxxx axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
c20 REPEAT('a',LENGTH(c20)) COUNT(*)
2
Creating an article aaaaaaaaaaaaaaaaaaa 1
aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
ALTER TABLE t1 ADD COLUMN c257 CHAR(257) NOT NULL;
ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# CHAR NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c CHAR NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c char(1) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('_');
SELECT HEX(c) FROM t1;
HEX(c)
5F
DROP TABLE t1;
#----------------------------------
# CHAR NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c CHAR NOT NULL DEFAULT '_'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c char(1) NO _
ALTER TABLE t1 ADD COLUMN err CHAR NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('_');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 5F
2 5F
DROP TABLE t1;
########################
# VARCHAR columns
########################
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
v0 VARCHAR(0) NOT NULL,
v1 VARCHAR(1) NOT NULL,
v64 VARCHAR(64) NOT NULL,
v65000 VARCHAR(65000) NOT NULL,
PRIMARY KEY (v64)
) ENGINE=xengine;
Warnings:
Note 1246 Converting column 'v65000' from VARCHAR to TEXT
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varchar(0) NO NULL
v1 varchar(1) NO NULL
v64 varchar(64) NO PRI NULL
v65000 mediumtext NO NULL
CREATE TABLE t2 (v VARCHAR(65532), PRIMARY KEY (v(255))) ENGINE=xengine;
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
SHOW COLUMNS IN t2;
Field Type Null Key Default Extra
v mediumtext NO PRI NULL
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
For developers who want to code on MariaDB or MySQL
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
For MariaDB / MySQL end users
* MariaDB Crash Course by Ben Forta
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o Free to read in the Knowledgebase!
* MySQL (4th Edition) by Paul DuBois
o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
* MySQL Cookbook by Paul DuBois
o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
* MySQL Admin Cookbook
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
SELECT v0,v1,v64,v65000 FROM t1;
v0 v1 v64 v65000
y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
o First MariaDB book!
o For people who want to learn SQL and the basics of MariaDB.
o Free to read in the Knowledgebase!
o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
o Now shipping. Purchase at Amazon.com or your favorite bookseller.
o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
* MariaDB Crash Course by Ben Forta
* MySQL (4th Edition) by Paul DuBois
* MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
* MySQL Admin Cookbook
* MySQL Cookbook by Paul DuBois
* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
For MariaDB / MySQL end users
For developers who want to code on MariaDB or MySQL
If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
Warnings:
Warning 1265 Data truncated for column 'v0' at row 1
Warning 1265 Data truncated for column 'v1' at row 1
Warning 1265 Data truncated for column 'v64' at row 1
INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, CONCAT('a',v65000), CONCAT(v65000,v1) FROM t1;
Warnings:
Warning 1265 Data truncated for column 'v0' at row 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
SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
v0 v1 v64 LENGTH(v65000)
0
a 0
H aHere is a list of recommended books on MariaDB and MySQL. We've 2966
a aabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abc 65011
y Once there, double check that an article doesn't already exist 2965
y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65010
ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) NOT NULL;
Warnings:
Note 1246 Converting column 'v65536' from VARCHAR to TEXT
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
v0 varchar(0) NO NULL
v1 varchar(1) NO NULL
v64 varchar(64) NO PRI NULL
v65000 mediumtext NO NULL
v65536 mediumtext NO NULL
DROP TABLE t1, t2;
DROP TABLE IF EXISTS t1;
#----------------------------------
# VARCHAR(64) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c VARCHAR(64) NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varchar(64) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test default');
SELECT HEX(c) FROM t1;
HEX(c)
746573742064656661756C74
DROP TABLE t1;
#----------------------------------
# VARCHAR(64) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c VARCHAR(64) NOT NULL DEFAULT 'test default'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c varchar(64) NO test default
ALTER TABLE t1 ADD COLUMN err VARCHAR(64) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test default');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 746573742064656661756C74
2 746573742064656661756C74
DROP TABLE t1;
########################
# date and time columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
d DATE NOT NULL,
dt DATETIME NOT NULL,
ts TIMESTAMP NOT NULL,
t TIME NOT NULL,
y YEAR NOT NULL,
y4 YEAR(4) NOT NULL,
y2 YEAR(4) NOT NULL,
pk DATETIME PRIMARY KEY
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d date NO NULL
dt datetime NO NULL
ts timestamp NO NULL
t time NO NULL
y year(4) NO NULL
y4 year(4) NO NULL
y2 year(4) NO NULL
pk datetime NO PRI NULL
SET @tm = '2012-04-09 05:27:00';
INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00','2012-12-12 12:12:12'),
('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99','2012-12-12 12:12:13'),
('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0','2012-12-12 12:12:14'),
(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm),'2012-12-12 12:12:15');
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
d dt ts t y y4 y2
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 2000
1000-01-01 1000-01-01 00:00:00 1970-01-01 03:00:01 -838:59:59 1901 1901 2000
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 2012
9999-12-31 9999-12-31 23:59:59 2038-01-19 06:14:07 838:59:59 2155 2155 1999
INSERT INTO t1 (d,dt,ts,t,y,y4,y2,pk) VALUES
('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1','2012-12-12 12:12:16');
Warnings:
Warning 1265 Data truncated for column 'd' at row 1
Warning 1264 Out of range value for column 'dt' at row 1
Warning 1264 Out of range value for column 'ts' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 'y' at row 1
Warning 1264 Out of range value for column 'y4' at row 1
Warning 1264 Out of range value for column 'y2' at row 1
SELECT d,dt,ts,t,y,y4,y2 FROM t1;
d dt ts t y y4 y2
1000-01-01 1000-01-01 00:00:00 1970-01-01 03:00:01 -838:59:59 1901 1901 2000
9999-12-31 9999-12-31 23:59:59 2038-01-19 06:14:07 838:59:59 2155 2155 1999
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 2000
2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 2012
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 0000
DROP TABLE t1;
SET TIMESTAMP=UNIX_TIMESTAMP('2013-12-12 12:12:12');
DROP TABLE IF EXISTS t1;
#----------------------------------
# DATE NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATE NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c date NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21');
SELECT HEX(c) FROM t1;
HEX(c)
323031322D31322D3231
DROP TABLE t1;
#----------------------------------
# DATE NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DATE NOT NULL DEFAULT '2012-12-21'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c date NO 2012-12-21
ALTER TABLE t1 ADD COLUMN err DATE NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031322D31322D3231
2 323031322D31322D3231
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DATETIME NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DATETIME NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c datetime NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
323031322D31322D32312031323A32313A3132
DROP TABLE t1;
#----------------------------------
# DATETIME NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DATETIME NOT NULL DEFAULT '2012-12-21 12:21:12'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c datetime NO 2012-12-21 12:21:12
ALTER TABLE t1 ADD COLUMN err DATETIME NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031322D31322D32312031323A32313A3132
2 323031322D31322D32312031323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TIMESTAMP NOT NULL column without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIMESTAMP NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c timestamp NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
323031322D31322D32312031323A32313A3132
DROP TABLE t1;
#----------------------------------
# TIMESTAMP NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TIMESTAMP NOT NULL DEFAULT '2012-12-21 12:21:12'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c timestamp NO 2012-12-21 12:21:12
ALTER TABLE t1 ADD COLUMN err TIMESTAMP NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 323031322D31322D32312031323A32313A3132
2 323031322D31322D32312031323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TIME NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TIME NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c time NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12:21:12');
SELECT HEX(c) FROM t1;
HEX(c)
31323A32313A3132
DROP TABLE t1;
#----------------------------------
# TIME NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TIME NOT NULL DEFAULT '12:21:12'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c time NO 12:21:12
ALTER TABLE t1 ADD COLUMN err TIME NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12:21:12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 31323A32313A3132
2 31323A32313A3132
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# YEAR NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012');
SELECT HEX(c) FROM t1;
HEX(c)
7DC
DROP TABLE t1;
#----------------------------------
# YEAR NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c YEAR NOT NULL DEFAULT '2012'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO 2012
ALTER TABLE t1 ADD COLUMN err YEAR NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('2012');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7DC
2 7DC
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# YEAR(4) NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c YEAR(4) NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12');
SELECT HEX(c) FROM t1;
HEX(c)
7DC
DROP TABLE t1;
#----------------------------------
# YEAR(4) NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c YEAR(4) NOT NULL DEFAULT '12'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c year(4) NO 2012
ALTER TABLE t1 ADD COLUMN err YEAR(4) NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('12');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7DC
2 7DC
DROP TABLE t1;
########################
# ENUM columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a ENUM('') NOT NULL,
b ENUM('test1','test2','test3','test4','test5') NOT NULL,
c ENUM('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NOT NULL,
PRIMARY KEY (b)
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a enum('') NO NULL
b enum('test1','test2','test3','test4','test5') NO PRI NULL
c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
SELECT a,b,c FROM t1;
a b c
test2 4
test5 2
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
test2 4
test5 2
ALTER TABLE t1 ADD COLUMN e ENUM('a','A') NOT NULL;
Warnings:
Note 1291 Column 'e' has duplicated value 'a' in ENUM
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a enum('') NO NULL
b enum('test1','test2','test3','test4','test5') NO PRI NULL
c enum('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') NO NULL
e enum('a','A') NO NULL
INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
SELECT a,b,c,e FROM t1;
a b c e
a
test2 4 a
test3 75 a
test5 2 a
SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
a b c e
test2 4 a
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# ENUM('test1','test2','test3') NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c ENUM('test1','test2','test3') NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c enum('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2');
SELECT HEX(c) FROM t1;
HEX(c)
7465737432
DROP TABLE t1;
#----------------------------------
# ENUM('test1','test2','test3') NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c ENUM('test1','test2','test3') NOT NULL DEFAULT 'test2'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c enum('test1','test2','test3') NO test2
ALTER TABLE t1 ADD COLUMN err ENUM('test1','test2','test3') NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7465737432
2 7465737432
DROP TABLE t1;
########################
# Fixed point columns (NUMERIC, DECIMAL)
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
d DECIMAL NOT NULL,
d0 DECIMAL(0) NOT NULL,
d1_1 DECIMAL(1,1) NOT NULL,
d10_2 DECIMAL(10,2) NOT NULL,
d60_10 DECIMAL(60,10) NOT NULL,
n NUMERIC NOT NULL,
n0_0 NUMERIC(0,0) NOT NULL,
n1 NUMERIC(1) NOT NULL,
n20_4 NUMERIC(20,4) NOT NULL,
n65_4 NUMERIC(65,4) NOT NULL,
pk NUMERIC NOT NULL PRIMARY KEY
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
d decimal(10,0) NO NULL
d0 decimal(10,0) NO NULL
d1_1 decimal(1,1) NO NULL
d10_2 decimal(10,2) NO NULL
d60_10 decimal(60,10) NO NULL
n decimal(10,0) NO NULL
n0_0 decimal(10,0) NO NULL
n1 decimal(1,0) NO NULL
n20_4 decimal(20,4) NO NULL
n65_4 decimal(65,4) NO NULL
pk decimal(10,0) NO PRI NULL
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807,1);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999,3);
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807,4);
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999,5);
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
6
);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999,7);
Warnings:
Warning 1264 Out of range value for column 'd' at row 1
Warning 1264 Out of range value for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Warning 1264 Out of range value for column 'd10_2' at row 1
Warning 1264 Out of range value for column 'd60_10' at row 1
Warning 1264 Out of range value for column 'n' at row 1
Warning 1264 Out of range value for column 'n0_0' at row 1
Warning 1264 Out of range value for column 'n1' at row 1
Warning 1264 Out of range value for column 'n20_4' at row 1
Warning 1264 Out of range value for column 'n65_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4,pk) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111,8);
Warnings:
Note 1265 Data truncated for column 'd' at row 1
Note 1265 Data truncated for column 'd0' at row 1
Warning 1264 Out of range value for column 'd1_1' at row 1
Note 1265 Data truncated for column 'd10_2' at row 1
Note 1265 Data truncated for column 'd60_10' at row 1
Note 1265 Data truncated for column 'n' at row 1
Note 1265 Data truncated for column 'n0_0' at row 1
Note 1265 Data truncated for column 'n1' at row 1
Note 1265 Data truncated for column 'n20_4' at row 1
Note 1265 Data truncated for column 'n65_4' at row 1
SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NOT NULL;
ERROR 42000: Too-big precision 66 specified for 'n66'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NOT NULL;
ERROR 42000: Too-big precision 66 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NOT NULL;
ERROR 42000: Too big scale 66 specified for column 'n66_66'. Maximum is 30.
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DECIMAL NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DECIMAL NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# DECIMAL NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DECIMAL NOT NULL DEFAULT 1.1
) ENGINE=xengine;
Warnings:
Note 1265 Data truncated for column 'c' at row 1
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO 1
ALTER TABLE t1 ADD COLUMN err DECIMAL NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# NUMERIC NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c NUMERIC NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# NUMERIC NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c NUMERIC NOT NULL DEFAULT 0
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c decimal(10,0) NO 0
ALTER TABLE t1 ADD COLUMN err NUMERIC NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# Floating point columns (FLOAT, DOUBLE)
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
f FLOAT NOT NULL,
f0 FLOAT(0) NOT NULL,
r1_1 REAL(1,1) NOT NULL,
f23_0 FLOAT(23) NOT NULL,
f20_3 FLOAT(20,3) NOT NULL,
d DOUBLE NOT NULL,
d1_0 DOUBLE(1,0) NOT NULL,
d10_10 DOUBLE PRECISION (10,10) NOT NULL,
d53 DOUBLE(53,0) NOT NULL,
d53_10 DOUBLE(53,10) NOT NULL,
pk DOUBLE NOT NULL PRIMARY KEY
) ENGINE=xengine;
Warnings:
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
Warning 1681 Specifying number of digits for floating point data types is deprecated and will be removed in a future release.
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
f float NO NULL
f0 float NO NULL
r1_1 double(1,1) NO NULL
f23_0 float NO NULL
f20_3 float(20,3) NO NULL
d double NO NULL
d1_0 double(1,0) NO NULL
d10_10 double(10,10) NO NULL
d53 double(53,0) NO NULL
d53_10 double(53,10) NO NULL
pk double NO PRI NULL
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999,1);
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d 11111111.111
d10_10 0.0123456789
d1_0 8
d53 1234566789123456800
d53_10 100000000000000000.0000000000
f0 12345.1
f20_3 56789.988
f23_0 123457000
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (0,0,0,0,0,0,0,0,0,0,2);
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
99999999999999999999999999999999999999,
99999999999999999999999999999999999999.9999999999999999,
0.9,
99999999999999999999999999999999999999.9,
99999999999999999.999,
999999999999999999999999999999999999999999999999999999999999999999999999999999999,
9,
0.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999,
3
);
Warnings:
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d 0
d 11111111.111
d 1e81
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 0
d1_0 8
d1_0 9
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f 0
f 1e38
f0 0
f0 12345.1
f0 1e38
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 0.0
r1_1 0.9
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999,4);
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
MAX(f) 1e38
MAX(d) 1e81
MAX(d10_10) 0.9999999999
MAX(d1_0) 9
MAX(d53) 100000000000000000000000000000000000000000000000000000
MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
MAX(f0) 1e38
MAX(f20_3) 99999998430674940.000
MAX(f23_0) 1e38
MAX(r1_1) 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
9999999999999999999999999999999999999999999999999999999999999.9999,
5
);
Warnings:
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e61
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f 3.40282e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (
999999999999999999999999999999999999999,
999999999999999999999999999999999999999.9999999999999999,
1.9,
999999999999999999999999999999999999999.9,
999999999999999999.999,
9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
99,
1.9999999999,
1999999999999999999999999999999999999999999999999999999,
19999999999999999999999999999999999999999999.9999999999,
6
);
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: '999999999999999999999999999999999999999999999999999999999999999999999999999999999'
Warning 1264 Out of range value for column 'f' at row 1
Warning 1264 Out of range value for column 'f0' at row 1
Warning 1264 Out of range value for column 'r1_1' at row 1
Warning 1264 Out of range value for column 'f23_0' at row 1
Warning 1264 Out of range value for column 'f20_3' at row 1
Warning 1264 Out of range value for column 'd1_0' at row 1
Warning 1264 Out of range value for column 'd10_10' at row 1
Warning 1264 Out of range value for column 'd53' at row 1
Warning 1264 Out of range value for column 'd53_10' at row 1
SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
f 12345.1
d -1e60
d 0
d 11111111.111
d 1e61
d 1e65
d 1e81
d10_10 -0.9999999999
d10_10 0.0000000000
d10_10 0.0123456789
d10_10 0.9999999999
d10_10 0.9999999999
d10_10 0.9999999999
d1_0 -9
d1_0 0
d1_0 8
d1_0 9
d1_0 9
d1_0 9
d53 -1000000000000000000000000000000
d53 0
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 100000000000000000000000000000000000000000000000000000
d53 1234566789123456800
d53_10 -10000000000000000000000000000000000000000000.0000000000
d53_10 0.0000000000
d53_10 100000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
d53_10 10000000000000000000000000000000000000000000.0000000000
f -1e24
f 0
f 1e38
f 3.40282e38
f 3.40282e38
f0 -100000000000
f0 0
f0 12345.1
f0 1e38
f0 3.40282e38
f0 3.40282e38
f20_3 -99999998430674940.000
f20_3 0.000
f20_3 56789.988
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f20_3 99999998430674940.000
f23_0 -1000
f23_0 0
f23_0 123457000
f23_0 1e38
f23_0 3.40282e38
f23_0 3.40282e38
r1_1 -0.9
r1_1 0.0
r1_1 0.9
r1_1 0.9
r1_1 0.9
r1_1 0.9
ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NOT NULL;
ERROR 42000: Display width out of range for column 'd0_0' (max = 255)
ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NOT NULL;
ERROR 42000: Too-big precision 256 specified for 'n66_6'. Maximum is 65.
ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NOT NULL;
ERROR 42000: Too big scale 35 specified for column 'n66_66'. Maximum is 30.
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# FLOAT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c FLOAT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c float NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# FLOAT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c FLOAT NOT NULL DEFAULT 1.1
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c float NO 1.1
ALTER TABLE t1 ADD COLUMN err FLOAT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1.1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# DOUBLE NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c DOUBLE NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c double NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# DOUBLE NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c DOUBLE NOT NULL DEFAULT 0
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c double NO 0
ALTER TABLE t1 ADD COLUMN err DOUBLE NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
########################
# INT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
i INT NOT NULL,
i0 INT(0) NOT NULL,
i1 INT(1) NOT NULL,
i20 INT(20) NOT NULL,
t TINYINT NOT NULL,
t0 TINYINT(0) NOT NULL,
t1 TINYINT(1) NOT NULL,
t20 TINYINT(20) NOT NULL,
s SMALLINT NOT NULL,
s0 SMALLINT(0) NOT NULL,
s1 SMALLINT(1) NOT NULL,
s20 SMALLINT(20) NOT NULL,
m MEDIUMINT NOT NULL,
m0 MEDIUMINT(0) NOT NULL,
m1 MEDIUMINT(1) NOT NULL,
m20 MEDIUMINT(20) NOT NULL,
b BIGINT NOT NULL,
b0 BIGINT(0) NOT NULL,
b1 BIGINT(1) NOT NULL,
b20 BIGINT(20) NOT NULL,
pk INT AUTO_INCREMENT PRIMARY KEY
) ENGINE=xengine;
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
i int(11) NO NULL
i0 int(11) NO NULL
i1 int(1) NO NULL
i20 int(20) NO NULL
t tinyint(4) NO NULL
t0 tinyint(4) NO NULL
t1 tinyint(1) NO NULL
t20 tinyint(20) NO NULL
s smallint(6) NO NULL
s0 smallint(6) NO NULL
s1 smallint(1) NO NULL
s20 smallint(20) NO NULL
m mediumint(9) NO NULL
m0 mediumint(9) NO NULL
m1 mediumint(1) NO NULL
m20 mediumint(20) NO NULL
b bigint(20) NO NULL
b0 bigint(20) NO NULL
b1 bigint(1) NO NULL
b20 bigint(20) NO NULL
pk int(11) NO PRI NULL auto_increment
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
Warnings:
Warning 1264 Out of range value for column 'i' at row 1
Warning 1264 Out of range value for column 'i0' at row 1
Warning 1264 Out of range value for column 'i1' at row 1
Warning 1264 Out of range value for column 'i20' at row 1
Warning 1264 Out of range value for column 't' at row 1
Warning 1264 Out of range value for column 't0' at row 1
Warning 1264 Out of range value for column 't1' at row 1
Warning 1264 Out of range value for column 't20' at row 1
Warning 1264 Out of range value for column 's' at row 1
Warning 1264 Out of range value for column 's0' at row 1
Warning 1264 Out of range value for column 's1' at row 1
Warning 1264 Out of range value for column 's20' at row 1
Warning 1264 Out of range value for column 'm' at row 1
Warning 1264 Out of range value for column 'm0' at row 1
Warning 1264 Out of range value for column 'm1' at row 1
Warning 1264 Out of range value for column 'm20' at row 1
Warning 1264 Out of range value for column 'b' at row 1
Warning 1264 Out of range value for column 'b0' at row 1
Warning 1264 Out of range value for column 'b1' at row 1
Warning 1264 Out of range value for column 'b20' at row 1
INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
Warnings:
Warning 1264 Out of range value for column 'i' at row 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
Warning 1264 Out of range value for column 'i' at row 5
Warning 1264 Out of range value for column 'i0' at row 5
Warning 1264 Out of range value for column 'i1' at row 5
Warning 1264 Out of range value for column 'i20' at row 5
Warning 1264 Out of range value for column 't' at row 5
Warning 1264 Out of range value for column 't0' at row 5
Warning 1264 Out of range value for column 't1' at row 5
Warning 1264 Out of range value for column 't20' at row 5
Warning 1264 Out of range value for column 's' at row 5
Warning 1264 Out of range value for column 's0' at row 5
Warning 1264 Out of range value for column 's1' at row 5
Warning 1264 Out of range value for column 's20' at row 5
Warning 1264 Out of range value for column 'm' at row 5
Warning 1264 Out of range value for column 'm0' at row 5
Warning 1264 Out of range value for column 'm1' at row 5
Warning 1264 Out of range value for column 'm20' at row 5
SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
ALTER TABLE t1 ADD COLUMN i257 INT(257) NOT NULL;
ERROR 42000: Display width out of range for column 'i257' (max = 255)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# INT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c INT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c int(11) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (2147483647);
SELECT HEX(c) FROM t1;
HEX(c)
7FFFFFFF
DROP TABLE t1;
#----------------------------------
# INT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c INT NOT NULL DEFAULT 2147483647
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c int(11) NO 2147483647
ALTER TABLE t1 ADD COLUMN err INT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (2147483647);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7FFFFFFF
2 7FFFFFFF
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYINT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(4) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (127);
SELECT HEX(c) FROM t1;
HEX(c)
7F
DROP TABLE t1;
#----------------------------------
# TINYINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYINT NOT NULL DEFAULT 127
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinyint(4) NO 127
ALTER TABLE t1 ADD COLUMN err TINYINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (127);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7F
2 7F
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# SMALLINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SMALLINT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c smallint(6) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
SELECT HEX(c) FROM t1;
HEX(c)
0
DROP TABLE t1;
#----------------------------------
# SMALLINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c SMALLINT NOT NULL DEFAULT 0
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c smallint(6) NO 0
ALTER TABLE t1 ADD COLUMN err SMALLINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (0);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 0
2 0
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMINT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumint(9) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
SELECT HEX(c) FROM t1;
HEX(c)
1
DROP TABLE t1;
#----------------------------------
# MEDIUMINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMINT NOT NULL DEFAULT 1
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumint(9) NO 1
ALTER TABLE t1 ADD COLUMN err MEDIUMINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (1);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 1
2 1
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# BIGINT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c BIGINT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bigint(20) NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (9223372036854775807);
SELECT HEX(c) FROM t1;
HEX(c)
7FFFFFFFFFFFFFFF
DROP TABLE t1;
#----------------------------------
# BIGINT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c BIGINT NOT NULL DEFAULT 9223372036854775807
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c bigint(20) NO 9223372036854775807
ALTER TABLE t1 ADD COLUMN err BIGINT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES (9223372036854775807);
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 7FFFFFFFFFFFFFFF
2 7FFFFFFFFFFFFFFF
DROP TABLE t1;
########################
# SET columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a SET('') NOT NULL,
b SET('test1','test2','test3','test4','test5') NOT NULL,
c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NOT NULL,
PRIMARY KEY (c)
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a set('') NO NULL
b set('test1','test2','test3','test4','test5') NO NULL
c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
INSERT INTO t1 (a,b,c) VALUES
('','test2,test3','01,34,44,,23'),
('',5,2),
(',','test4,test2','');
Warnings:
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
test1,test3 02
test2,test3 01,23,34,44
test2,test4
INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'c' at row 1
SELECT a,b,c FROM t1;
a b c
01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50'51,52,53,54,55,56,57,58,59,60,61,62,63,64
test1,test3 02
test2,test3 01,23,34,44
test2,test4
ALTER TABLE t1 ADD COLUMN e SET('a','A') NOT NULL;
Warnings:
Note 1291 Column 'e' has duplicated value 'a' in SET
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
a set('') NO NULL
b set('test1','test2','test3','test4','test5') NO NULL
c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50''51','52','53','54','55','56','57','58','59','60','61','62','63','64') NO PRI NULL
e set('a','A') NO NULL
ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') NOT NULL;
ERROR HY000: Too many strings for column f and SET
SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
a b c e
test2,test3 01,23,34,44
test2,test4
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# SET('test1','test2','test3') NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c SET('test1','test2','test3') NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c set('test1','test2','test3') NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2,test3');
SELECT HEX(c) FROM t1;
HEX(c)
74657374322C7465737433
DROP TABLE t1;
#----------------------------------
# SET('test1','test2','test3') NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c SET('test1','test2','test3') NOT NULL DEFAULT 'test2,test3'
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c set('test1','test2','test3') NO test2,test3
ALTER TABLE t1 ADD COLUMN err SET('test1','test2','test3') NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('test2,test3');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1 74657374322C7465737433
2 74657374322C7465737433
DROP TABLE t1;
########################
# TEXT columns
########################
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
t TEXT NOT NULL,
t0 TEXT(0) NOT NULL,
t1 TEXT(1) NOT NULL,
t300 TEXT(300) NOT NULL,
tm TEXT(65535) NOT NULL,
t70k TEXT(70000) NOT NULL,
t17m TEXT(17000000) NOT NULL,
tt TINYTEXT NOT NULL,
m MEDIUMTEXT NOT NULL,
l LONGTEXT NOT NULL
) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
t text NO NULL
t0 tinytext NO NULL
t1 tinytext NO NULL
t300 text NO NULL
tm mediumtext NO NULL
t70k mediumtext NO NULL
t17m longtext NO NULL
tt tinytext NO NULL
m mediumtext NO NULL
l longtext NO NULL
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
('','','','','','','','','',''),
('a','b','c','d','e','f','g','h','i','j'),
('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
Warnings:
Warning 1265 Data truncated for column 't0' at row 4
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 255 255 65535 65535 1048576 1048576 255 1048576 1048576
INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
Warnings:
Warning 1265 Data truncated for column 't' at row 1
Warning 1265 Data truncated for column 't0' at row 1
Warning 1265 Data truncated for column 't1' at row 1
Warning 1265 Data truncated for column 't300' at row 1
Warning 1265 Data truncated for column '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 255 255 65535 65535 1048576 1048576 255 1048576 1048576
65535 255 255 65535 65536 1048576 1048576 255 1048576 1048576
ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296) NOT NULL;
ERROR 42000: Display width out of range for column 'ttt' (max = 4294967295)
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TEXT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c text NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TEXT NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c text NO NULL
ALTER TABLE t1 ADD COLUMN err TEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# TINYTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c TINYTEXT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinytext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# TINYTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c TINYTEXT NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c tinytext NO NULL
ALTER TABLE t1 ADD COLUMN err TINYTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# MEDIUMTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c MEDIUMTEXT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# MEDIUMTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c MEDIUMTEXT NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c mediumtext NO NULL
ALTER TABLE t1 ADD COLUMN err MEDIUMTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;
DROP TABLE IF EXISTS t1;
#----------------------------------
# LONGTEXT NOT NULL columns without a default
#----------------------------------
CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, c LONGTEXT NOT NULL) ENGINE=xengine;
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longtext NO NULL
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
SELECT HEX(c) FROM t1;
HEX(c)
DROP TABLE t1;
#----------------------------------
# LONGTEXT NOT NULL columns with a default
#----------------------------------
CREATE TABLE t1 (
pk INT AUTO_INCREMENT PRIMARY KEY,
c LONGTEXT NOT NULL DEFAULT ''
) ENGINE=xengine;
Warnings:
Warning 1101 BLOB, TEXT, GEOMETRY or JSON column 'c' can't have a default value
SHOW COLUMNS IN t1;
Field Type Null Key Default Extra
pk int(11) NO PRI NULL auto_increment
c longtext NO NULL
ALTER TABLE t1 ADD COLUMN err LONGTEXT NOT NULL DEFAULT NULL;
ERROR 42000: Invalid default value for 'err'
INSERT INTO t1 (c) VALUES (NULL);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) VALUES ('');
INSERT INTO t1 () VALUES ();
SELECT pk, HEX(c) FROM t1 ORDER BY pk;
pk HEX(c)
1
2
DROP TABLE t1;