Created
February 11, 2021 22:24
-
-
Save jamiejackson/f41f6f4d0dec9759d5ea303fdb4b4f4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-------+--------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+--------+------+-----+---------+-------+ | |
| a | bit(1) | YES | | NULL | | | |
| b | bit(1) | YES | | NULL | | | |
| c | bit(1) | YES | | NULL | | | |
+-------+--------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
+-------+------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+------------+------+-----+---------+-------+ | |
| a | tinyint(1) | YES | | NULL | | | |
| b | tinyint(1) | YES | | NULL | | | |
| c | tinyint(1) | YES | | NULL | | | |
+-------+------------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-------+--------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+--------+------+-----+---------+-------+ | |
| a | bit(1) | YES | | NULL | | | |
| b | bit(1) | YES | | NULL | | | |
| c | bit(1) | YES | | NULL | | | |
+-------+--------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
+-------+------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+------------+------+-----+---------+-------+ | |
| a | tinyint(1) | YES | | NULL | | | |
| b | tinyint(1) | YES | | NULL | | | |
| c | tinyint(1) | YES | | NULL | | | |
+-------+------------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.6' | |
services: | |
dbexp: | |
image: ${IMAGE:-mariadb:10.5} | |
container_name: dbexp | |
environment: | |
MYSQL_ALLOW_EMPTY_PASSWORD: 1 | |
MYSQL_ROOT_PASSWORD: '' | |
ports: | |
- 3306:3306 | |
volumes: | |
- ./:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create schema if not exists `test`; | |
use test; | |
drop table if exists test; | |
create table test( | |
a bit, | |
b bit, | |
c bit | |
); | |
insert into test(a,b,c) values(0, 1, NULL); | |
show columns from test.test; | |
# a couple of union examples | |
select a, b, c from test | |
union select 0, NULL, 1; | |
select a, b, c from test | |
union select 0, 1, 1; | |
# CONVERT TO TINYINT | |
alter table test.test modify column a boolean default NULL NULL; | |
alter table test.test modify column b boolean default NULL NULL; | |
alter table test.test modify column c boolean default NULL NULL; | |
show columns from test.test; | |
# same union examples as above | |
select a, b, c from test | |
union select 0, NULL, 1; | |
select a, b, c from test | |
union select 0, 1, 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ IMAGE=mariadb:10.2 docker-compose up -d | |
$ docker exec dbexp bash -c 'mysql --table < /app/script.sql' | |
+-------+--------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+--------+------+-----+---------+-------+ | |
| a | bit(1) | YES | | NULL | | | |
| b | bit(1) | YES | | NULL | | | |
| c | bit(1) | YES | | NULL | | | |
+-------+--------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
+-------+------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+------------+------+-----+---------+-------+ | |
| a | tinyint(1) | YES | | NULL | | | |
| b | tinyint(1) | YES | | NULL | | | |
| c | tinyint(1) | YES | | NULL | | | |
+-------+------------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
$ | |
$ | |
$ | |
$ docker-compose down | |
$ IMAGE=mariadb:10.5 docker-compose up -d | |
$ docker exec dbexp bash -c 'mysql --table < /app/script.sql' | |
+-------+--------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+--------+------+-----+---------+-------+ | |
| a | bit(1) | YES | | NULL | | | |
| b | bit(1) | YES | | NULL | | | |
| c | bit(1) | YES | | NULL | | | |
+-------+--------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
+-------+------------+------+-----+---------+-------+ | |
| Field | Type | Null | Key | Default | Extra | | |
+-------+------------+------+-----+---------+-------+ | |
| a | tinyint(1) | YES | | NULL | | | |
| b | tinyint(1) | YES | | NULL | | | |
| c | tinyint(1) | YES | | NULL | | | |
+-------+------------+------+-----+---------+-------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | NULL | 1 | | |
+------+------+------+ | |
+------+------+------+ | |
| a | b | c | | |
+------+------+------+ | |
| 0 | 1 | NULL | | |
| 0 | 1 | 1 | | |
+------+------+------+ | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment