2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once 'libraries/common.inc.php';
13 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
18 require 'libraries/tbl_common.php';
19 $url_query .= '&goto=tbl_operations.php&back=tbl_operations.php';
20 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
23 * Gets relation settings
25 $cfgRelation = PMA_getRelationsParam();
28 * Gets available MySQL charsets and storage engines
30 require_once 'libraries/mysql_charsets.lib.php';
31 require_once 'libraries/StorageEngine.class.php';
34 * Class for partition management
36 require_once 'libraries/Partition.class.php';
38 // reselect current db (needed in some cases probably due to
39 // the calling of relation.lib.php)
40 PMA_DBI_select_db($GLOBALS['db']);
43 * Gets tables informations
46 require 'libraries/tbl_info.inc.php';
48 // define some globals here, for improved syntax in the conditionals
49 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
50 // set initial value of these globals, based on the current table engine
51 PMA_set_global_variables_for_engine($tbl_storage_engine);
54 // the value for transactional can be implicit
55 // (no create option found, in this case it means 1)
56 // or explicit (option found with a value of 0 or 1)
57 // ($transactional may have been set by libraries/tbl_info.inc.php,
58 // from the $create_options)
59 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
60 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
64 $table_alters = array();
67 * If the table has to be moved to some other database
69 if (isset($_REQUEST['submit_move']) ||
isset($_REQUEST['submit_copy'])) {
71 include_once 'tbl_move_copy.php';
74 * If the table has to be maintained
76 if (isset($_REQUEST['table_maintenance'])) {
77 include_once 'sql.php';
81 * Updates table comment, type and options if required
83 if (isset($_REQUEST['submitoptions'])) {
85 $warning_messages = array();
87 if (isset($_REQUEST['new_name'])) {
88 if ($pma_table->rename($_REQUEST['new_name'])) {
89 $_message .= $pma_table->getLastMessage();
91 $GLOBALS['table'] = $pma_table->getName();
95 $_message .= $pma_table->getLastError();
99 if (isset($_REQUEST['comment'])
100 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']
102 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddSlashes($_REQUEST['comment']) . '\'';
104 if (! empty($_REQUEST['new_tbl_storage_engine'])
105 && strtolower($_REQUEST['new_tbl_storage_engine']) !== strtolower($tbl_storage_engine)
107 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_storage_engine'];
108 $tbl_storage_engine = $_REQUEST['new_tbl_storage_engine'];
109 // reset the globals for the new engine
110 PMA_set_global_variables_for_engine($tbl_storage_engine);
112 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
113 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
117 if (! empty($_REQUEST['tbl_collation'])
118 && $_REQUEST['tbl_collation'] !== $tbl_collation
120 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
123 if (($is_myisam_or_aria ||
$is_isam)
124 && isset($_REQUEST['new_pack_keys'])
125 && $_REQUEST['new_pack_keys'] != (string)$pack_keys
127 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
130 $checksum = empty($checksum) ?
'0' : '1';
131 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ?
'0' : '1';
132 if ($is_myisam_or_aria
133 && $_REQUEST['new_checksum'] !== $checksum
135 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
138 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ?
'0' : '1';
140 && $_REQUEST['new_transactional'] !== $transactional
142 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
145 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ?
'0' : '1';
147 && $_REQUEST['new_page_checksum'] !== $page_checksum
149 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
152 $delay_key_write = empty($delay_key_write) ?
'0' : '1';
153 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ?
'0' : '1';
154 if ($is_myisam_or_aria
155 && $_REQUEST['new_delay_key_write'] !== $delay_key_write
157 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
160 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
161 && ! empty($_REQUEST['new_auto_increment'])
162 && (! isset($auto_increment) ||
$_REQUEST['new_auto_increment'] !== $auto_increment)
164 $table_alters[] = 'auto_increment = ' . PMA_sqlAddSlashes($_REQUEST['new_auto_increment']);
167 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
168 && ! empty($_REQUEST['new_row_format'])
169 && (! isset($row_format) ||
strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))
171 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddSlashes($_REQUEST['new_row_format']);
174 if (count($table_alters) > 0) {
175 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
176 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
178 $result .= PMA_DBI_query($sql_query) ?
true : false;
180 unset($table_alters);
181 foreach (PMA_DBI_get_warnings() as $warning) {
182 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
183 // and if TRANSACTIONAL was set, the system reports an error;
184 // I discussed with a Maria developer and he agrees that this
185 // should not be reported with a Level of Error, so here
186 // I just ignore it. But there are other 1478 messages
187 // that it's better to show.
188 if (! ($_REQUEST['new_tbl_storage_engine'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
189 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
190 . ' ' . $warning['Message'];
196 * Reordering the table has been requested by the user
198 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
200 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
201 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
202 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
203 $sql_query .= ' DESC';
206 $result = PMA_DBI_query($sql_query);
210 * A partition operation has been requested by the user
212 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
213 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'] . ';';
214 $result = PMA_DBI_query($sql_query);
218 // to avoid showing the old value (for example the AUTO_INCREMENT) after
219 // a change, clear the cache
220 PMA_Table
::$cache = array();
221 $page_checksum = $checksum = $delay_key_write = 0;
222 include 'libraries/tbl_info.inc.php';
227 * Displays top menu links in non ajax requests
229 if (!isset($_REQUEST['ajax_request'])) {
230 include_once 'libraries/tbl_links.inc.php';
232 if (isset($result) && empty($message_to_show)) {
233 // set to success by default, because result set could be empty
234 // (for example, a table rename)
236 if (empty($_message)) {
237 $_message = $result ?
$message = PMA_Message
::success(__('Your SQL query has been executed successfully')) : PMA_Message
::error(__('Error'));
238 // $result should exist, regardless of $_message
239 $_type = $result ?
'success' : 'error';
240 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
241 $extra_data['sql_query'] = PMA_showMessage(null, $sql_query);
242 PMA_ajaxResponse($_message, $_message->isSuccess(), $extra_data);
245 if (! empty($warning_messages)) {
246 $_message = new PMA_Message
;
247 $_message->addMessages($warning_messages);
248 $_message->isError(true);
249 if ( $_REQUEST['ajax_request'] == true) {
250 PMA_ajaxResponse($_message, false);
252 unset($warning_messages);
255 PMA_showMessage($_message, $sql_query, $_type);
256 unset($_message, $_type);
259 $url_params['goto'] =
260 $url_params['back'] = 'tbl_operations.php';
265 $columns = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']);
271 <!-- Order the table
-->
272 <div
class="operations_half_width">
273 <form method
="post" id
="alterTableOrderby" action
="tbl_operations.php" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
274 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
275 <fieldset id
="fieldset_table_order">
276 <legend
><?php
echo __('Alter table order by'); ?
></legend
>
277 <select name
="order_field">
279 foreach ($columns as $fieldname) {
280 echo ' <option value="' . htmlspecialchars($fieldname['Field']) . '">'
281 . htmlspecialchars($fieldname['Field']) . '</option>' . "\n";
285 </select
> <?php
echo __('(singly)'); ?
>
286 <select name
="order_order">
287 <option value
="asc"><?php
echo __('Ascending'); ?
></option
>
288 <option value
="desc"><?php
echo __('Descending'); ?
></option
>
291 <fieldset
class="tblFooters">
292 <input type
="submit" name
="submitorderby" value
="<?php echo __('Go'); ?>" />
298 <div
class="operations_half_width">
299 <form method
="post" action
="tbl_operations.php"
300 onsubmit
="return emptyFormElements(this, 'new_name')">
301 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
302 <input type
="hidden" name
="reload" value
="1" />
303 <input type
="hidden" name
="what" value
="data" />
304 <fieldset id
="fieldset_table_rename">
305 <legend
><?php
echo __('Move table to (database<b>.</b>table):'); ?
></legend
>
306 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
308 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
312 <select name
="target_db">
313 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
318  
;<strong
>.</strong
> 
;
319 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
320 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br
/>
322 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
323 // next value but users can decide if they want it or not for the operation
325 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_mv" checked
="checked" />
326 <label
for="checkbox_auto_increment_mv"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
328 <fieldset
class="tblFooters">
329 <input type
="submit" name
="submit_move" value
="<?php echo __('Go'); ?>" />
335 if (strstr($show_comment, '; InnoDB free') === false) {
336 if (strstr($show_comment, 'InnoDB free') === false) {
337 // only user entered comment
338 $comment = $show_comment;
340 // here we have just InnoDB generated part
344 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
345 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
348 // PACK_KEYS: MyISAM or ISAM
349 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
350 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
352 // Here should be version check for InnoDB, however it is supported
353 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
357 <!-- Table options
-->
358 <div
class="operations_half_width clearfloat">
359 <form method
="post" action
="tbl_operations.php">
360 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
361 <input type
="hidden" name
="reload" value
="1" />
363 <legend
><?php
echo __('Table options'); ?
></legend
>
366 <!-- Change table name
-->
367 <tr
><td
><?php
echo __('Rename table to'); ?
></td
>
368 <td
><input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
369 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
373 <!-- Table comments
-->
374 <tr
><td
><?php
echo __('Table comments'); ?
></td
>
375 <td
><input type
="text" name
="comment" maxlength
="60" size
="30"
376 value
="<?php echo htmlspecialchars($comment); ?>" onfocus
="this.select()" />
377 <input type
="hidden" name
="prev_comment" value
="<?php echo htmlspecialchars($comment); ?>" />
381 <!-- Storage engine
-->
382 <tr
><td
><?php
echo __('Storage Engine'); ?
>
383 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
385 <td
><?php
echo PMA_StorageEngine
::getHtmlSelect('new_tbl_storage_engine', null, $tbl_storage_engine); ?
>
389 <!-- Table character set
-->
390 <tr
><td
><?php
echo __('Collation'); ?
></td
>
391 <td
><?php
echo PMA_generateCharsetDropdownBox(
392 PMA_CSDROPDOWN_COLLATION
,
393 'tbl_collation', null, $tbl_collation, false, 3
398 if ($is_myisam_or_aria ||
$is_isam) {
401 <td
><label
for="new_pack_keys">PACK_KEYS
</label
></td
>
402 <td
><select name
="new_pack_keys" id
="new_pack_keys">
403 <option value
="DEFAULT"
404 <?php
if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?
>
407 <?php
if ($pack_keys == '0') echo 'selected="selected"'; ?
>
410 <?php
if ($pack_keys == '1') echo 'selected="selected"'; ?
>
416 } // end if (MYISAM|ISAM)
418 if ($is_myisam_or_aria) {
420 <tr
><td
><label
for="new_checksum">CHECKSUM
</label
></td
>
421 <td
><input type
="checkbox" name
="new_checksum" id
="new_checksum"
423 <?php
echo (isset($checksum) && $checksum == 1)
424 ?
' checked="checked"'
429 <tr
><td
><label
for="new_delay_key_write">DELAY_KEY_WRITE
</label
></td
>
430 <td
><input type
="checkbox" name
="new_delay_key_write" id
="new_delay_key_write"
432 <?php
echo (isset($delay_key_write) && $delay_key_write == 1)
433 ?
' checked="checked"'
443 <tr
><td
><label
for="new_transactional">TRANSACTIONAL
</label
></td
>
444 <td
><input type
="checkbox" name
="new_transactional" id
="new_transactional"
446 <?php
echo (isset($transactional) && $transactional == 1)
447 ?
' checked="checked"'
452 <tr
><td
><label
for="new_page_checksum">PAGE_CHECKSUM
</label
></td
>
453 <td
><input type
="checkbox" name
="new_page_checksum" id
="new_page_checksum"
455 <?php
echo (isset($page_checksum) && $page_checksum == 1)
456 ?
' checked="checked"'
464 if (isset($auto_increment) && strlen($auto_increment) > 0
465 && ($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
468 <tr
><td
><label
for="auto_increment_opt">AUTO_INCREMENT
</label
></td
>
469 <td
><input type
="text" name
="new_auto_increment" id
="auto_increment_opt"
470 value
="<?php echo $auto_increment; ?>" /></td
>
473 } // end if (MYISAM|INNODB)
475 // the outer array is for engines, the inner array contains the dropdown
476 // option values as keys then the dropdown option labels
478 $possible_row_formats = array(
481 'DYNAMIC' => 'DYNAMIC',
486 'DYNAMIC' => 'DYNAMIC',
491 'DYNAMIC' => 'DYNAMIC'
495 'DYNAMIC' => 'DYNAMIC'
498 'COMPACT' => 'COMPACT',
499 'REDUNDANT' => 'REDUNDANT')
502 $innodb_engine_plugin = PMA_StorageEngine
::getEngine('innodb');
503 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
504 if (!empty($innodb_plugin_version)) {
505 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
507 $innodb_file_format = '';
509 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
510 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
511 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
513 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
515 // for MYISAM there is also COMPRESSED but it can be set only by the
516 // myisampack utility, so don't offer here the choice because if we
517 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
518 // does not return a warning
519 // (if the table was compressed, it can be seen on the Structure page)
521 if (isset($possible_row_formats[$tbl_storage_engine])) {
522 $current_row_format = strtoupper($showtable['Row_format']);
523 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
525 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format');
526 unset($possible_row_formats, $current_row_format);
533 <fieldset
class="tblFooters">
534 <input type
="submit" name
="submitoptions" value
="<?php echo __('Go'); ?>" />
540 <div
class="operations_half_width">
541 <form method
="post" action
="tbl_operations.php" name
="copyTable" id
="copyTable" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>
542 onsubmit
="return emptyFormElements(this, 'new_name')">
543 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
544 <input type
="hidden" name
="reload" value
="1" />
546 <legend
><?php
echo __('Copy table to (database<b>.</b>table):'); ?
></legend
>
547 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
549 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
553 <select name
="target_db">
554 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
559  
;<strong
>.</strong
> 
;
560 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()" value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br
/>
563 'structure' => __('Structure only'),
564 'data' => __('Structure and data'),
565 'dataonly' => __('Data only'));
566 PMA_display_html_radio('what', $choices, 'data', true);
570 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
571 <label
for="checkbox_drop"><?php
echo sprintf(__('Add %s'), 'DROP TABLE'); ?
></label
><br
/>
572 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_cp" />
573 <label
for="checkbox_auto_increment_cp"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
575 // display "Add constraints" choice only if there are
577 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
579 <input type
="checkbox" name
="add_constraints" value
="1" id
="checkbox_constraints" />
580 <label
for="checkbox_constraints"><?php
echo __('Add constraints'); ?
></label
><br
/>
583 if (isset($_COOKIE['pma_switch_to_new'])
584 && $_COOKIE['pma_switch_to_new'] == 'true'
586 $pma_switch_to_new = 'true';
589 <input type
="checkbox" name
="switch_to_new" value
="true"
590 id
="checkbox_switch"<?php
echo
591 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
592 ?
' checked="checked"'
594 <label
for="checkbox_switch"><?php
echo __('Switch to copied table'); ?
></label
>
596 <fieldset
class="tblFooters">
597 <input type
="submit" name
="submit_copy" value
="<?php echo __('Go'); ?>" />
602 <br
class="clearfloat"/>
604 <div
class="operations_half_width">
606 <legend
><?php
echo __('Table maintenance'); ?
></legend
>
608 <ul id
="tbl_maintenance" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
610 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
611 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
612 if ($is_myisam_or_aria ||
$is_innodb) {
613 $this_url_params = array_merge(
616 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']),
617 'table_maintenance' => 'Go',
621 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
622 <?php
echo __('Check table'); ?
></a
>
623 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?
>
628 $this_url_params = array_merge(
630 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB;')
633 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
634 <?php
echo __('Defragment table'); ?
></a
>
635 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?
>
639 if ($is_myisam_or_aria ||
$is_berkeleydb) {
640 $this_url_params = array_merge(
643 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
644 'table_maintenance' => 'Go',
648 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
649 <?php
echo __('Analyze table'); ?
></a
>
650 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?
>
654 if ($is_myisam_or_aria && !PMA_DRIZZLE
) {
655 $this_url_params = array_merge(
658 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
659 'table_maintenance' => 'Go',
663 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
664 <?php
echo __('Repair table'); ?
></a
>
665 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?
>
669 if (($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) && !PMA_DRIZZLE
) {
670 $this_url_params = array_merge(
673 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
674 'table_maintenance' => 'Go',
678 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
679 <?php
echo __('Optimize table'); ?
></a
>
680 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?
>
684 } // end MYISAM or BERKELEYDB case
685 $this_url_params = array_merge(
688 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
689 'message_to_show' => sprintf(
690 __('Table %s has been flushed'),
691 htmlspecialchars($GLOBALS['table'])
697 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
698 <?php
echo __('Flush the table (FLUSH)'); ?
></a
>
699 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?
>
704 <?php
if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?
>
705 <div
class="operations_half_width">
706 <fieldset
class="caution">
707 <legend
><?php
echo __('Delete data or table'); ?
></legend
>
711 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
712 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
713 $this_url_params = array_merge(
716 'sql_query' => $this_sql_query,
717 'goto' => 'tbl_structure.php',
719 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
723 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'id="truncate_tbl_anchor" class="ajax"' : ''); ?
>>
724 <?php
echo __('Empty the table (TRUNCATE)'); ?
></a
>
725 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?
>
729 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
730 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
731 $this_url_params = array_merge(
734 'sql_query' => $this_sql_query,
735 'goto' => 'db_operations.php',
738 'message_to_show' => sprintf(($tbl_is_view ?
__('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
739 // table name is needed to avoid running
740 // PMA_relationsCleanupDatabase() on the whole db later
741 'table' => $GLOBALS['table'],
745 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'id="drop_tbl_anchor"' : ''); ?
>>
746 <?php
echo __('Delete the table (DROP)'); ?
></a
>
747 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?
>
758 <br
class="clearfloat">
759 <?php
if (PMA_Partition
::havePartitioning()) {
760 $partition_names = PMA_Partition
::getPartitionNames($db, $table);
761 // show the Partition maintenance section only if we detect a partition
762 if (! is_null($partition_names[0])) {
764 <div
class="operations_half_width">
765 <form method
="post" action
="tbl_operations.php">
766 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
768 <legend
><?php
echo __('Partition maintenance'); ?
></legend
>
770 $html_select = '<select name="partition_name">' . "\n";
771 foreach ($partition_names as $one_partition) {
772 $one_partition = htmlspecialchars($one_partition);
773 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
775 $html_select .= '</select>' . "\n";
776 printf(__('Partition %s'), $html_select);
777 unset($partition_names, $one_partition, $html_select);
779 'ANALYZE' => __('Analyze'),
780 'CHECK' => __('Check'),
781 'OPTIMIZE' => __('Optimize'),
782 'REBUILD' => __('Rebuild'),
783 'REPAIR' => __('Repair'));
784 PMA_display_html_radio('partition_operation', $choices, '', false);
786 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
787 // I'm not sure of the best way to display that; this link does
788 // not depend on the Go button
789 $this_url_params = array_merge(
792 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;'
796 <br
/><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
797 <?php
echo __('Remove partitioning'); ?
></a
>
799 <fieldset
class="tblFooters">
800 <input type
="submit" name
="submit_partition" value
="<?php echo __('Go'); ?>" />
808 // Referential integrity check
809 // The Referential integrity check was intended for the non-InnoDB
810 // tables for which the relations are defined in pmadb
811 // so I assume that if the current table is InnoDB, I don't display
812 // this choice (InnoDB maintains integrity by itself)
814 if ($cfgRelation['relwork'] && ! $is_innodb) {
815 PMA_DBI_select_db($GLOBALS['db']);
816 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
820 <!-- Referential integrity check
-->
821 <div
class="operations_half_width">
823 <legend
><?php
echo __('Check referential integrity:'); ?
></legend
>
827 foreach ($foreign AS $master => $arr) {
828 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
829 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
830 . PMA_backquote($arr['foreign_table']);
831 if ($arr['foreign_table'] == $GLOBALS['table']) {
832 $foreign_table = $GLOBALS['table'] . '1';
833 $join_query .= ' AS ' . PMA_backquote($foreign_table);
835 $foreign_table = $arr['foreign_table'];
837 $join_query .= ' ON '
838 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
839 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
841 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
843 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
845 $this_url_params = array_merge(
847 array('sql_query' => $join_query)
851 . PMA_generate_common_url($this_url_params)
852 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
853 . '</a></li>' . "\n";
854 } // foreach $foreign
855 unset($foreign_table, $join_query);
861 } // end if ($foreign)
863 } // end if (!empty($cfg['Server']['relation']))
867 * Displays the footer
869 require 'libraries/footer.inc.php';
872 function PMA_set_global_variables_for_engine($tbl_storage_engine)
874 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
876 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
877 $upper_tbl_storage_engine = strtoupper($tbl_storage_engine);
879 //Options that apply to MYISAM usually apply to ARIA
880 $is_myisam_or_aria = ($upper_tbl_storage_engine == 'MYISAM' ||
$upper_tbl_storage_engine == 'ARIA' ||
$upper_tbl_storage_engine == 'MARIA');
881 $is_aria = ($upper_tbl_storage_engine == 'ARIA');
883 $is_isam = ($upper_tbl_storage_engine == 'ISAM');
884 $is_innodb = ($upper_tbl_storage_engine == 'INNODB');
885 $is_berkeleydb = ($upper_tbl_storage_engine == 'BERKELEYDB');
886 $is_pbxt = ($upper_tbl_storage_engine == 'PBXT');