SHARE
TWEET

Enum8

mr_felixoid Sep 11th, 2017 (edited) 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :) select Rebill as r, count() from test group by r                    
  2.  
  3. SELECT
  4.     Rebill AS r,
  5.     count()
  6. FROM test
  7. GROUP BY r
  8.  
  9. ┌───r─┬─count()─┐
  10. │  no │       7 │
  11. │ yes │       7 │
  12. └─────┴─────────┘
  13.  
  14. 2 rows in set. Elapsed: 0.007 sec.
  15.  
  16. :) select toString(Rebill) as r, count() from test group by r          
  17.  
  18. SELECT
  19.     toString(Rebill) AS r,
  20.     count()
  21. FROM test
  22. GROUP BY r
  23.  
  24. ┌─r───┬─count()─┐
  25. │ no  │       7 │
  26. │ yes │       7 │
  27. └─────┴─────────┘
  28.  
  29. 2 rows in set. Elapsed: 0.006 sec.
  30.  
  31. :) select hex(MD5(toString(Rebill))) as r, count() from test group by r
  32.  
  33. SELECT
  34.     hex(MD5(toString(Rebill))) AS r,
  35.     count()
  36. FROM test
  37. GROUP BY r
  38.  
  39. ┌─r────────────────────────────────┬─count()─┐
  40. │ 00C66F1A036BD8F9CB709CB8D925D3D9 │       7 │
  41. │ 7F2D79E06E99B5969A90C4560C2ECB83 │       7 │
  42. └──────────────────────────────────┴─────────┘
  43.  
  44. 2 rows in set. Elapsed: 0.006 sec.
  45.  
  46. :) select hex(MD5(toString('yes')))                                    
  47.  
  48. SELECT hex(MD5(toString('yes')))
  49.  
  50. ┌─hex(MD5(toString(\'yes\')))──────┐
  51. │ A6105C0A611B41B08F1209506350279E │
  52. └──────────────────────────────────┘
  53.  
  54. 1 rows in set. Elapsed: 0.003 sec.
  55.  
  56. :) select * from test where Rebill = 'yes';
  57.  
  58. SELECT *
  59. FROM test
  60. WHERE Rebill = 'yes'
  61.  
  62. Received exception from server:
  63. Code: 169. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Primary key expression contains comparison between inconvertible types: Enum8('no' = 0, 'yes' = 1) and String inside Rebill = 'yes'.
  64.  
  65. 0 rows in set. Elapsed: 0.043 sec.
  66.  
  67. :) select * from test where toString(Rebill) = 'yes';
  68.  
  69. SELECT *
  70. FROM test
  71. WHERE toString(Rebill) = 'yes'
  72.  
  73. Ok.
  74.  
  75. 0 rows in set. Elapsed: 0.006 sec.
  76.  
  77. :) select * from test where toString(Rebill) = "yes";
  78.  
  79. SELECT *
  80. FROM test
  81. WHERE toString(Rebill) = yes
  82.  
  83. Received exception from server:
  84. Code: 47. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Unknown identifier: yes.
  85.  
  86. 0 rows in set. Elapsed: 0.023 sec.
  87.  
  88. :) select * from test where toString(Rebill) = 'yes';
  89.  
  90. SELECT *
  91. FROM test
  92. WHERE toString(Rebill) = 'yes'
  93.  
  94. Ok.
  95.  
  96. 0 rows in set. Elapsed: 0.008 sec.
  97.  
  98. :) select * from test where toString(Rebill) = 'yes';
  99.  
  100. SELECT *
  101. FROM test
  102. WHERE toString(Rebill) = 'yes'
  103.  
  104. Ok.
  105.  
  106. 0 rows in set. Elapsed: 0.007 sec.
  107.  
  108. :) select hex(MD5(toString(1)))    
  109.  
  110. SELECT hex(MD5(toString(1)))
  111.  
  112. ┌─hex(MD5(toString(1)))────────────┐
  113. │ C4CA4238A0B923820DCC509A6F75849B │
  114. └──────────────────────────────────┘
  115.  
  116. 1 rows in set. Elapsed: 0.003 sec.
  117.  
  118. :) select hex(MD5(toString(0)))
  119.  
  120. SELECT hex(MD5(toString(0)))
  121.  
  122. ┌─hex(MD5(toString(0)))────────────┐
  123. │ CFCD208495D565EF66E7DFF9F98764DA │
  124. └──────────────────────────────────┘
  125.  
  126. 1 rows in set. Elapsed: 0.003 sec.
  127.  
  128. :) show create table test
  129.  
  130. SHOW CREATE TABLE test
  131.  
  132. ┌─statement───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  133. │ CREATE TABLE default.test ( Rebill Enum8(\'no\' = 0, \'yes\' = 1),  SomeTrash UInt32 DEFAULT rand(),  Date Date) ENGINE = MergeTree(Date, Rebill, 8192) │
  134. └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top