index.twig 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <div class="container-fluid">
  2. {% if not hide_order_table %}
  3. <form method="post" id="alterTableOrderby" action="{{ url('/table/operations') }}">
  4. {{ get_hidden_inputs(db, table) }}
  5. <input type="hidden" name="submitorderby" value="1">
  6. <div class="card mb-2">
  7. <div class="card-header">{% trans 'Alter table order by' %}</div>
  8. <div class="card-body">
  9. <div class="form-row">
  10. <div class="col-auto">
  11. <label class="sr-only" for="tableOrderFieldSelect">{% trans 'Column' %}</label>
  12. <select id="tableOrderFieldSelect" class="form-control" name="order_field" aria-describedby="tableOrderFieldSelectHelp">
  13. {% for column in columns %}
  14. <option value="{{ column.Field }}">{{ column.Field }}</option>
  15. {% endfor %}
  16. </select>
  17. <small id="tableOrderFieldSelectHelp" class="form-text text-muted">
  18. {% trans %}(singly){% context %}Alter table order by a single field.{% endtrans %}
  19. </small>
  20. </div>
  21. <div class="col-auto">
  22. <div class="form-check">
  23. <input class="form-check-input" id="tableOrderAscRadio" name="order_order" type="radio" value="asc" checked>
  24. <label class="form-check-label" for="tableOrderAscRadio">{% trans 'Ascending' %}</label>
  25. </div>
  26. <div class="form-check">
  27. <input class="form-check-input" id="tableOrderDescRadio" name="order_order" type="radio" value="desc">
  28. <label class="form-check-label" for="tableOrderDescRadio">{% trans 'Descending' %}</label>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="card-footer text-right">
  34. <input class="btn btn-primary" type="submit" value="{% trans 'Go' %}">
  35. </div>
  36. </div>
  37. </form>
  38. {% endif %}
  39. <form method="post" action="{{ url('/table/operations') }}" id="moveTableForm" class="ajax" onsubmit="return Functions.emptyCheckTheField(this, 'new_name')">
  40. {{ get_hidden_inputs(db, table) }}
  41. <input type="hidden" name="reload" value="1">
  42. <input type="hidden" name="what" value="data">
  43. <div class="card mb-2">
  44. <div class="card-header">{% trans 'Move table to (database.table)' %}</div>
  45. <div class="card-body">
  46. <div class="form-group form-row">
  47. <div class="col-auto">
  48. <div class="input-group">
  49. {% if database_list is not empty %}
  50. <select id="moveTableDatabaseInput" class="form-control" name="target_db" aria-label="{% trans 'Database' %}">
  51. {% for each_db in database_list %}
  52. <option value="{{ each_db.name }}"{{ each_db.is_selected ? ' selected' }}>{{ each_db.name }}</option>
  53. {% endfor %}
  54. </select>
  55. {% else %}
  56. <input id="moveTableDatabaseInput" class="form-control" type="text" maxlength="100" name="target_db" value="{{ db }}" aria-label="{% trans 'Database' %}">
  57. {% endif %}
  58. <div class="input-group-prepend input-group-append">
  59. <span class="input-group-text">.</span>
  60. </div>
  61. <input class="form-control" type="text" required="required" name="new_name" maxlength="64" value="{{ table }}" aria-label="{% trans 'Table' %}">
  62. </div>
  63. </div>
  64. </div>
  65. <div class="form-check">
  66. <input class="form-check-input" type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv">
  67. <label class="form-check-label" for="checkbox_auto_increment_mv">{% trans 'Add AUTO_INCREMENT value' %}</label>
  68. </div>
  69. <div class="form-check">
  70. <input class="form-check-input" type="checkbox" name="adjust_privileges" value="1" id="checkbox_privileges_tables_move"
  71. {%- if has_privileges %} checked{% else %} title="
  72. {%- trans 'You don\'t have sufficient privileges to perform this operation; Please refer to the documentation for more details.' %}" disabled{% endif %}>
  73. <label class="form-check-label" for="checkbox_privileges_tables_move">
  74. {% trans 'Adjust privileges' %}
  75. {{ show_docu('faq', 'faq6-39') }}
  76. </label>
  77. </div>
  78. </div>
  79. <div class="card-footer text-right">
  80. <input class="btn btn-primary" type="submit" name="submit_move" value="{% trans 'Go' %}">
  81. </div>
  82. </div>
  83. </form>
  84. <form method="post" action="{{ url('/table/operations') }}" id="tableOptionsForm" class="ajax">
  85. {{ get_hidden_inputs(db, table) }}
  86. <input type="hidden" name="reload" value="1">
  87. <input type="hidden" name="submitoptions" value="1">
  88. <input type="hidden" name="prev_comment" value="{{ table_comment }}">
  89. {% if has_auto_increment %}
  90. <input type="hidden" name="hidden_auto_increment" value="{{ auto_increment }}">
  91. {% endif %}
  92. <div class="card mb-2">
  93. <div class="card-header">{% trans 'Table options' %}</div>
  94. <div class="card-body">
  95. <div class="form-group form-inline">
  96. <div class="form-group">
  97. <label for="renameTableInput">{% trans 'Rename table to' %}</label>
  98. <input class="form-control mx-2" id="renameTableInput" type="text" name="new_name" maxlength="64" value="{{ table }}" required>
  99. </div>
  100. <div class="form-check">
  101. <input class="form-check-input" type="checkbox" name="adjust_privileges" value="1" id="checkbox_privileges_table_options"
  102. {%- if has_privileges %} checked{% else %} title="
  103. {%- trans 'You don\'t have sufficient privileges to perform this operation; Please refer to the documentation for more details.' %}" disabled{% endif %}>
  104. <label class="form-check-label" for="checkbox_privileges_table_options">
  105. {% trans 'Adjust privileges' %}
  106. {{ show_docu('faq', 'faq6-39') }}
  107. </label>
  108. </div>
  109. </div>
  110. <div class="form-group form-inline">
  111. <label for="tableCommentsInput">{% trans 'Table comments' %}</label>
  112. <input class="form-control ml-2" id="tableCommentsInput" type="text" name="comment" maxlength="2048" value="{{ table_comment }}">
  113. </div>
  114. <div class="form-group form-inline">
  115. <label class="text-nowrap" for="newTableStorageEngineSelect">
  116. {% trans 'Storage engine' %}
  117. {{ show_mysql_docu('Storage_engines') }}
  118. </label>
  119. <select class="form-control ml-2" name="new_tbl_storage_engine" id="newTableStorageEngineSelect">
  120. {% for engine in storage_engines %}
  121. <option value="{{ engine.name }}"{% if engine.comment is not empty %} title="{{ engine.comment }}"{% endif %}
  122. {{- engine.name|lower == storage_engine|lower or (storage_engine is empty and engine.is_default) ? ' selected' }}>
  123. {{- engine.name -}}
  124. </option>
  125. {% endfor %}
  126. </select>
  127. </div>
  128. <div class="form-group form-inline">
  129. <label for="collationSelect">{% trans 'Collation' %}</label>
  130. <select class="form-control mx-2" id="collationSelect" lang="en" dir="ltr" name="tbl_collation">
  131. <option value=""></option>
  132. {% for charset in charsets %}
  133. <optgroup label="{{ charset.getName() }}" title="{{ charset.getDescription() }}">
  134. {% for collation in collations[charset.getName()] %}
  135. <option value="{{ collation.getName() }}" title="{{ collation.getDescription() }}"{{ tbl_collation == collation.getName() ? ' selected' }}>
  136. {{ collation.getName() }}
  137. </option>
  138. {% endfor %}
  139. </optgroup>
  140. {% endfor %}
  141. </select>
  142. <div class="form-check">
  143. <input class="form-check-input" type="checkbox" name="change_all_collations" value="1" id="checkbox_change_all_collations">
  144. <label class="form-check-label" for="checkbox_change_all_collations">{% trans 'Change all column collations' %}</label>
  145. </div>
  146. </div>
  147. {% if has_pack_keys %}
  148. <div class="form-group form-inline">
  149. <label for="new_pack_keys">PACK_KEYS</label>
  150. <select class="form-control ml-2" name="new_pack_keys" id="new_pack_keys">
  151. <option value="DEFAULT"{{ pack_keys == 'DEFAULT' ? ' selected' }}>DEFAULT</option>
  152. <option value="0"{{ pack_keys == '0' ? ' selected' }}>0</option>
  153. <option value="1"{{ pack_keys == '1' ? ' selected' }}>1</option>
  154. </select>
  155. </div>
  156. {% endif %}
  157. {% if has_checksum_and_delay_key_write %}
  158. <div class="form-group form-check">
  159. <input class="form-check-input" type="checkbox" name="new_checksum" id="new_checksum" value="1"{{ checksum == '1' ? ' checked' }}>
  160. <label class="form-check-label" for="new_checksum">CHECKSUM</label>
  161. </div>
  162. <div class="form-group form-check">
  163. <input class="form-check-input" type="checkbox" name="new_delay_key_write" id="new_delay_key_write" value="1"{{ delay_key_write == '1' ? ' checked' }}>
  164. <label class="form-check-label" for="new_delay_key_write">DELAY_KEY_WRITE</label>
  165. </div>
  166. {% endif %}
  167. {% if has_transactional_and_page_checksum %}
  168. <div class="form-group form-check">
  169. <input class="form-check-input" type="checkbox" name="new_transactional" id="new_transactional" value="1"{{ transactional == '1' ? ' checked' }}>
  170. <label class="form-check-label" for="new_transactional">TRANSACTIONAL</label>
  171. </div>
  172. <div class="form-group form-check">
  173. <input class="form-check-input" type="checkbox" name="new_page_checksum" id="new_page_checksum" value="1"{{ page_checksum == '1' ? ' checked' }}>
  174. <label class="form-check-label" for="new_page_checksum">PAGE_CHECKSUM</label>
  175. </div>
  176. {% endif %}
  177. {% if has_auto_increment %}
  178. <div class="form-group form-inline">
  179. <label for="auto_increment_opt">AUTO_INCREMENT</label>
  180. <input class="form-control ml-2" id="auto_increment_opt" type="number" name="new_auto_increment" value="{{ auto_increment }}">
  181. </div>
  182. {% endif %}
  183. {% if row_formats is not empty %}
  184. <div class="form-group form-inline">
  185. <label for="new_row_format">ROW_FORMAT</label>
  186. <select class="form-control ml-2" id="new_row_format" name="new_row_format">
  187. {% for row_format in row_formats %}
  188. <option value="{{ row_format }}"{{ row_format == row_format_current|upper ? ' selected' }}>{{ row_format }}</option>
  189. {% endfor %}
  190. </select>
  191. </div>
  192. {% endif %}
  193. </div>
  194. <div class="card-footer text-right">
  195. <input class="btn btn-primary" type="submit" value="{% trans 'Go' %}">
  196. </div>
  197. </div>
  198. </form>
  199. <form method="post" action="{{ url('/table/operations') }}" name="copyTable" id="copyTable" class="ajax" onsubmit="return Functions.emptyCheckTheField(this, 'new_name')">
  200. {{ get_hidden_inputs(db, table) }}
  201. <input type="hidden" name="reload" value="1">
  202. <div class="card mb-2">
  203. <div class="card-header">{% trans 'Copy table to (database.table)' %}</div>
  204. <div class="card-body">
  205. <div class="form-group form-row">
  206. <div class="col-auto">
  207. <div class="input-group">
  208. {% if database_list is not empty %}
  209. <select class="form-control" name="target_db" aria-label="{% trans 'Database' %}">
  210. {% for each_db in database_list %}
  211. <option value="{{ each_db.name }}"{{ each_db.is_selected ? ' selected' }}>{{ each_db.name }}</option>
  212. {% endfor %}
  213. </select>
  214. {% else %}
  215. <input class="form-control" type="text" maxlength="100" name="target_db" value="{{ db }}" aria-label="{% trans 'Database' %}">
  216. {% endif %}
  217. <div class="input-group-prepend input-group-append">
  218. <span class="input-group-text">.</span>
  219. </div>
  220. <input class="form-control" type="text" name="new_name" maxlength="64" value="{{ table }}" aria-label="{% trans 'Table' %}" required>
  221. </div>
  222. </div>
  223. </div>
  224. <div class="form-group">
  225. <div class="form-check">
  226. <input class="form-check-input" type="radio" name="what" id="whatRadio1" value="structure">
  227. <label class="form-check-label" for="whatRadio1">
  228. {% trans 'Structure only' %}
  229. </label>
  230. </div>
  231. <div class="form-check">
  232. <input class="form-check-input" type="radio" name="what" id="whatRadio2" value="data" checked>
  233. <label class="form-check-label" for="whatRadio2">
  234. {% trans 'Structure and data' %}
  235. </label>
  236. </div>
  237. <div class="form-check">
  238. <input class="form-check-input" type="radio" name="what" id="whatRadio3" value="dataonly">
  239. <label class="form-check-label" for="whatRadio3">
  240. {% trans 'Data only' %}
  241. </label>
  242. </div>
  243. </div>
  244. <div class="form-group">
  245. <div class="form-check">
  246. <input class="form-check-input" type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop">
  247. <label class="form-check-label" for="checkbox_drop">{{ 'Add %s'|trans|format('DROP TABLE') }}</label>
  248. </div>
  249. <div class="form-check">
  250. <input class="form-check-input" type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp">
  251. <label class="form-check-label" for="checkbox_auto_increment_cp">{% trans 'Add AUTO_INCREMENT value' %}</label>
  252. </div>
  253. {% if has_foreign_keys %}
  254. <div class="form-check">
  255. <input class="form-check-input" type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" checked>
  256. <label class="form-check-label" for="checkbox_constraints">{% trans 'Add constraints' %}</label>
  257. </div>
  258. {% endif %}
  259. <div class="form-check">
  260. <input class="form-check-input" type="checkbox" name="adjust_privileges" value="1" id="checkbox_adjust_privileges"
  261. {%- if has_privileges %} checked{% else %} title="
  262. {%- trans 'You don\'t have sufficient privileges to perform this operation; Please refer to the documentation for more details.' %}" disabled{% endif %}>
  263. <label class="form-check-label" for="checkbox_adjust_privileges">
  264. {% trans 'Adjust privileges' %}
  265. {{ show_docu('faq', 'faq6-39') }}
  266. </label>
  267. </div>
  268. <div class="form-check">
  269. <input class="form-check-input" type="checkbox" name="switch_to_new" value="true" id="checkbox_switch"{{ switch_to_new ? ' checked' }}>
  270. <label class="form-check-label" for="checkbox_switch">{% trans 'Switch to copied table' %}</label>
  271. </div>
  272. </div>
  273. </div>
  274. <div class="card-footer text-right">
  275. <input class="btn btn-primary" type="submit" name="submit_copy" value="{% trans 'Go' %}">
  276. </div>
  277. </div>
  278. </form>
  279. <div class="card mb-2">
  280. <div class="card-header">{% trans 'Table maintenance' %}</div>
  281. <ul class="list-group list-group-flush" id="tbl_maintenance">
  282. {% if storage_engine in ['MYISAM', 'ARIA', 'INNODB', 'BERKELEYDB', 'TOKUDB'] %}
  283. <li class="list-group-item">
  284. <a href="{{ url('/table/maintenance/analyze') }}" data-post="{{ get_common({'db': db, 'table': table, 'selected_tbl': [table]}) }}">
  285. {% trans 'Analyze table' %}
  286. </a>
  287. {{ show_mysql_docu('ANALYZE_TABLE') }}
  288. </li>
  289. {% endif %}
  290. {% if storage_engine in ['MYISAM', 'ARIA', 'INNODB', 'TOKUDB'] %}
  291. <li class="list-group-item">
  292. <a href="{{ url('/table/maintenance/check') }}" data-post="{{ get_common({'db': db, 'table': table, 'selected_tbl': [table]}) }}">
  293. {% trans 'Check table' %}
  294. </a>
  295. {{ show_mysql_docu('CHECK_TABLE') }}
  296. </li>
  297. {% endif %}
  298. <li class="list-group-item">
  299. <a href="{{ url('/table/maintenance/checksum') }}" data-post="{{ get_common({'db': db, 'table': table, 'selected_tbl': [table]}) }}">
  300. {% trans 'Checksum table' %}
  301. </a>
  302. {{ show_mysql_docu('CHECKSUM_TABLE') }}
  303. </li>
  304. {% if storage_engine == 'INNODB' %}
  305. <li class="list-group-item">
  306. <a class="maintain_action ajax" href="{{ url('/sql') }}" data-post="{{ get_common(url_params|merge({'sql_query': 'ALTER TABLE ' ~ backquote(table) ~ ' ENGINE = InnoDB;'})) }}">
  307. {% trans 'Defragment table' %}
  308. </a>
  309. {{ show_mysql_docu('InnoDB_File_Defragmenting') }}
  310. </li>
  311. {% endif %}
  312. <li class="list-group-item">
  313. <a class="maintain_action ajax" href="{{ url('/sql') }}" data-post="{{ get_common(url_params|merge({
  314. 'sql_query': 'FLUSH TABLE ' ~ backquote(table),
  315. 'message_to_show': 'Table %s has been flushed.'|trans|format(table|e),
  316. 'reload': true
  317. })) }}">
  318. {% trans 'Flush the table (FLUSH)' %}
  319. </a>
  320. {{ show_mysql_docu('FLUSH') }}
  321. </li>
  322. {% if storage_engine in ['MYISAM', 'ARIA', 'INNODB', 'BERKELEYDB', 'TOKUDB'] %}
  323. <li class="list-group-item">
  324. <a href="{{ url('/table/maintenance/optimize') }}" data-post="{{ get_common({'db': db, 'table': table, 'selected_tbl': [table]}) }}">
  325. {% trans 'Optimize table' %}
  326. </a>
  327. {{ show_mysql_docu('OPTIMIZE_TABLE') }}
  328. </li>
  329. {% endif %}
  330. {% if storage_engine in ['MYISAM', 'ARIA'] %}
  331. <li class="list-group-item">
  332. <a href="{{ url('/table/maintenance/repair') }}" data-post="{{ get_common({'db': db, 'table': table, 'selected_tbl': [table]}) }}">
  333. {% trans 'Repair table' %}
  334. </a>
  335. {{ show_mysql_docu('REPAIR_TABLE') }}
  336. </li>
  337. {% endif %}
  338. </ul>
  339. </div>
  340. {% if not is_system_schema %}
  341. <div class="card mb-2">
  342. <div class="card-header">{% trans 'Delete data or table' %}</div>
  343. <ul class="list-group list-group-flush">
  344. {% if not is_view %}
  345. <li class="list-group-item">
  346. {{ link_or_button(
  347. url('/sql', url_params|merge({
  348. 'sql_query': 'TRUNCATE TABLE ' ~ backquote(table),
  349. 'goto': url('/table/structure'),
  350. 'reload': true,
  351. 'message_to_show': 'Table %s has been emptied.'|trans|format(table)|e
  352. })),
  353. 'Empty the table (TRUNCATE)'|trans,
  354. {
  355. 'id': 'truncate_tbl_anchor',
  356. 'class': 'text-danger ajax'
  357. }
  358. ) }}
  359. {{ show_mysql_docu('TRUNCATE_TABLE') }}
  360. </li>
  361. {% endif %}
  362. <li class="list-group-item">
  363. {{ link_or_button(
  364. url('/sql', url_params|merge({
  365. 'sql_query': 'DROP TABLE ' ~ backquote(table),
  366. 'goto': url('/database/operations'),
  367. 'reload': true,
  368. 'purge': true,
  369. 'message_to_show': is_view ? 'View %s has been dropped.'|trans|format(table)|e : 'Table %s has been dropped.'|trans|format(table)|e,
  370. 'table': table
  371. })),
  372. 'Delete the table (DROP)'|trans,
  373. {
  374. 'id': 'drop_tbl_anchor',
  375. 'class': 'text-danger ajax'
  376. }
  377. ) }}
  378. {{ show_mysql_docu('DROP_TABLE') }}
  379. </li>
  380. </ul>
  381. </div>
  382. {% endif %}
  383. {% if partitions is not empty %}
  384. <form id="partitionsForm" class="ajax" method="post" action="{{ url('/table/operations') }}">
  385. {{ get_hidden_inputs(db, table) }}
  386. <input type="hidden" name="submit_partition" value="1">
  387. <div class="card mb-2">
  388. <div class="card-header">
  389. {% trans 'Partition maintenance' %}
  390. {{ show_mysql_docu('partitioning_maintenance') }}
  391. </div>
  392. <div class="card-body">
  393. <div class="form-group">
  394. <label for="partition_name">{% trans 'Partition' %}</label>
  395. <select class="form-control" id="partition_name" name="partition_name[]" multiple required>
  396. {% for partition in partitions %}
  397. <option value="{{ partition }}"{{ loop.first ? ' selected' }}>{{ partition }}</option>
  398. {% endfor %}
  399. </select>
  400. </div>
  401. <div class="form-group form-check-inline">
  402. {% for value, description in partitions_choices %}
  403. <div class="form-check">
  404. <input class="form-check-input" type="radio" name="partition_operation" id="partitionOperationRadio{{ value|capitalize }}" value="{{ value }}"{{ value == 'ANALYZE' ? ' checked' }}>
  405. <label class="form-check-label" for="partitionOperationRadio{{ value|capitalize }}">{{ description }}</label>
  406. </div>
  407. {% endfor %}
  408. </div>
  409. <div class="form-text">
  410. <a href="{{ url('/sql', url_params|merge({
  411. 'sql_query': 'ALTER TABLE ' ~ backquote(table) ~ ' REMOVE PARTITIONING;'
  412. })) }}">{% trans 'Remove partitioning' %}</a>
  413. </div>
  414. </div>
  415. <div class="card-footer text-right">
  416. <input class="btn btn-primary" type="submit" value="{% trans 'Go' %}">
  417. </div>
  418. </div>
  419. </form>
  420. {% endif %}
  421. {% if foreigners is not empty %}
  422. <div class="card mb-2">
  423. <div class="card-header">{% trans 'Check referential integrity' %}</div>
  424. <ul class="list-group list-group-flush">
  425. {% for foreign in foreigners %}
  426. <li class="list-group-item">
  427. <a class="text-nowrap" href="{{ url('/sql', foreign.params) }}">
  428. {{ foreign.master }} -> {{ foreign.db }}.{{ foreign.table }}.{{ foreign.field }}
  429. </a>
  430. </li>
  431. {% endfor %}
  432. </ul>
  433. </div>
  434. {% endif %}
  435. </div>