Advertisement
Guest User

Untitled

a guest
Apr 28th, 2019
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. # Ran the following
  2. alter table table_two add column `aincid` int unsigned PRIMARY KEY AUTO_INCREMENT first;
  3. alter table table_two modify `id` varchar(200) not null default 'unknownID';
  4. alter table table_one modify `id` varchar(200) not null; # added NOT NULL to table_one as well
  5.  
  6.  
  7. > show create table table_two
  8. CREATE TABLE `table_one` (
  9. `id` varchar(200) NOT NULL,
  10. `RecordKey` varchar(50) DEFAULT NULL,
  11. `VersionStat` varchar(200) DEFAULT NULL,
  12. `Status` varchar(200) DEFAULT NULL,
  13. `VersionNumber` varchar(50) DEFAULT NULL,
  14. `VersionDate` varchar(20) DEFAULT NULL,
  15. `PublishDate` varchar(20) DEFAULT NULL,
  16. `DistStart` varchar(20) DEFAULT NULL,
  17. `DistCommStat` varchar(2000) DEFAULT NULL,
  18. `BrandName` varchar(100) DEFAULT NULL,
  19. `VersionModelNumber` varchar(100) DEFAULT NULL,
  20. `Catalog` varchar(100) DEFAULT NULL,
  21. `dwNumber` varchar(100) DEFAULT NULL,
  22. `CompanyName` varchar(500) DEFAULT NULL,
  23. `DeviceCount` varchar(200) DEFAULT NULL,
  24. `description` varchar(3000) DEFAULT NULL,
  25. `Exemption` varchar(1100) DEFAULT NULL,
  26. `PreMarket` varchar(1500) DEFAULT NULL,
  27. `DevDRMT` varchar(1000) DEFAULT NULL,
  28. `DTKit` varchar(200) DEFAULT NULL,
  29. `Combination` varchar(250) DEFAULT NULL,
  30. `Usage` varchar(500) DEFAULT NULL,
  31. `SingleBatch` varchar(50) DEFAULT NULL,
  32. `SerialNumber` varchar(250) DEFAULT NULL,
  33. `ManuDate` varchar(20) DEFAULT NULL,
  34. `ExpDate` varchar(20) DEFAULT NULL,
  35. `Donation` varchar(50) DEFAULT NULL,
  36. `LabeldWithMLO` varchar(50) DEFAULT NULL,
  37. `NLabledMLO` varchar(50) DEFAULT NULL,
  38. `MLOStatus` varchar(1000) DEFAULT NULL,
  39. `BTT` varchar(50) DEFAULT NULL,
  40. `OPP` varchar(50) DEFAULT NULL,
  41. `BRC` varchar(50) DEFAULT NULL,
  42. `PriorUse` varchar(100) DEFAULT NULL,
  43. PRIMARY KEY (`id`)
  44. ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  45.  
  46. > show create table table_two
  47. CREATE TABLE `table_two` (
  48. `aincid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  49. `id` varchar(200) NOT NULL DEFAULT 'unknownID',
  50. `Name` varchar(200) DEFAULT NULL,
  51. `deviceType` varchar(50) DEFAULT NULL,
  52. `issuedBy` varchar(200) DEFAULT NULL,
  53. `avNum` varchar(50) DEFAULT NULL,
  54. `quant` varchar(50) DEFAULT NULL,
  55. `discDate` varchar(50) DEFAULT NULL,
  56. `PkgStatus` varchar(50) DEFAULT NULL,
  57. `Type` varchar(50) DEFAULT NULL,
  58. PRIMARY KEY (`aincid`),
  59. KEY `idx_table_two_id` (`id`)
  60. ) ENGINE=InnoDB AUTO_INCREMENT=2457646 DEFAULT CHARSET=latin1
  61.  
  62.  
  63. > explain SELECT SQL_NO_CACHE DISTINCT ...
  64.  
  65. ******************** 1. row *********************
  66. id: 1
  67. select_type: SIMPLE
  68. table: d
  69. partitions:
  70. type: ALL
  71. possible_keys: PRIMARY
  72. key:
  73. key_len:
  74. ref:
  75. rows: 1894942
  76. filtered: 100.00
  77. Extra: Using temporary
  78. ******************** 2. row *********************
  79. id: 1
  80. select_type: SIMPLE
  81. table: i
  82. partitions:
  83. type: ref
  84. possible_keys: idx_table_two_id
  85. key: idx_table_two_id
  86. key_len: 202
  87. ref: mydb.d.id
  88. rows: 1
  89. filtered: 100.00
  90. Extra:
  91.  
  92.  
  93. ###############
  94. # 5.7 indexes
  95. ###############
  96. > SHOW INDEX FROM table_one
  97.  
  98. ******************** 1. row *********************
  99. Table: table_one
  100. Non_unique: 0
  101. Key_name: PRIMARY
  102. Seq_in_index: 1
  103. Column_name: id
  104. Collation: A
  105. Cardinality: 1894942
  106. Sub_part:
  107. Packed:
  108. Null:
  109. Index_type: BTREE
  110. Comment:
  111. Index_comment:
  112. 1 rows in set
  113.  
  114. > SHOW INDEX FROM table_two
  115.  
  116. ******************** 1. row *********************
  117. Table: table_two
  118. Non_unique: 0
  119. Key_name: PRIMARY
  120. Seq_in_index: 1
  121. Column_name: aincid
  122. Collation: A
  123. Cardinality: 2477600
  124. Sub_part:
  125. Packed:
  126. Null:
  127. Index_type: BTREE
  128. Comment:
  129. Index_comment:
  130. ******************** 2. row *********************
  131. Table: table_two
  132. Non_unique: 1
  133. Key_name: idx_table_two_id
  134. Seq_in_index: 1
  135. Column_name: id
  136. Collation: A
  137. Cardinality: 2116953
  138. Sub_part:
  139. Packed:
  140. Null:
  141. Index_type: BTREE
  142. Comment:
  143. Index_comment:
  144. 2 rows in set
  145.  
  146.  
  147. ###############
  148. # 5.6 indexes
  149. ###############
  150.  
  151. > SHOW INDEX FROM table_one
  152.  
  153. ******************** 1. row *********************
  154. Table: table_one
  155. Non_unique: 0
  156. Key_name: PRIMARY
  157. Seq_in_index: 1
  158. Column_name: id
  159. Collation: A
  160. Cardinality: 1596593
  161. Sub_part:
  162. Packed:
  163. Null:
  164. Index_type: BTREE
  165. Comment:
  166. Index_comment:
  167. 1 rows in set
  168.  
  169. > SHOW INDEX FROM table_two
  170.  
  171. ******************** 1. row *********************
  172. Table: table_two
  173. Non_unique: 1
  174. Key_name: idx_table_two_id
  175. Seq_in_index: 1
  176. Column_name: id
  177. Collation: A
  178. Cardinality: 2384739
  179. Sub_part:
  180. Packed:
  181. Null: YES
  182. Index_type: BTREE
  183. Comment:
  184. Index_comment:
  185. 1 rows in set
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement