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']) {
101 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddSlashes($_REQUEST['comment']) . '\'';
103 if (! empty($_REQUEST['new_tbl_storage_engine'])
104 && strtolower($_REQUEST['new_tbl_storage_engine']) !== strtolower($tbl_storage_engine)) {
105 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_storage_engine'];
106 $tbl_storage_engine = $_REQUEST['new_tbl_storage_engine'];
107 // reset the globals for the new engine
108 PMA_set_global_variables_for_engine($tbl_storage_engine);
110 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
111 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
115 if (! empty($_REQUEST['tbl_collation'])
116 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
117 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
120 if (($is_myisam_or_aria ||
$is_isam)
121 && isset($_REQUEST['new_pack_keys'])
122 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
123 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
126 $checksum = empty($checksum) ?
'0' : '1';
127 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ?
'0' : '1';
128 if ($is_myisam_or_aria
129 && $_REQUEST['new_checksum'] !== $checksum) {
130 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
133 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ?
'0' : '1';
135 && $_REQUEST['new_transactional'] !== $transactional) {
136 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
139 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ?
'0' : '1';
141 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
142 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
145 $delay_key_write = empty($delay_key_write) ?
'0' : '1';
146 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ?
'0' : '1';
147 if ($is_myisam_or_aria
148 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
149 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
152 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
153 && ! empty($_REQUEST['new_auto_increment'])
154 && (! isset($auto_increment) ||
$_REQUEST['new_auto_increment'] !== $auto_increment)) {
155 $table_alters[] = 'auto_increment = ' . PMA_sqlAddSlashes($_REQUEST['new_auto_increment']);
158 if (($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)
159 && ! empty($_REQUEST['new_row_format'])
160 && (! isset($row_format) ||
strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
161 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddSlashes($_REQUEST['new_row_format']);
164 if (count($table_alters) > 0) {
165 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
166 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
167 $result .= PMA_DBI_query($sql_query) ?
true : false;
169 unset($table_alters);
170 foreach (PMA_DBI_get_warnings() as $warning) {
171 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
172 // and if TRANSACTIONAL was set, the system reports an error;
173 // I discussed with a Maria developer and he agrees that this
174 // should not be reported with a Level of Error, so here
175 // I just ignore it. But there are other 1478 messages
176 // that it's better to show.
177 if (! ($_REQUEST['new_tbl_storage_engine'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
178 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
179 . ' ' . $warning['Message'];
185 * Reordering the table has been requested by the user
187 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
189 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
190 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
191 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
192 $sql_query .= ' DESC';
194 $result = PMA_DBI_query($sql_query);
198 * A partition operation has been requested by the user
200 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
201 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
202 $result = PMA_DBI_query($sql_query);
206 // to avoid showing the old value (for example the AUTO_INCREMENT) after
207 // a change, clear the cache
208 PMA_Table
::$cache = array();
209 $page_checksum = $checksum = $delay_key_write = 0;
210 include 'libraries/tbl_info.inc.php';
215 * Displays top menu links in non ajax requests
217 if (!isset($_REQUEST['ajax_request'])) {
218 include_once 'libraries/tbl_links.inc.php';
220 if (isset($result) && empty($message_to_show)) {
221 // set to success by default, because result set could be empty
222 // (for example, a table rename)
224 if (empty($_message)) {
225 $_message = $result ?
$message = PMA_Message
::success(__('Your SQL query has been executed successfully')) : PMA_Message
::error(__('Error'));
226 // $result should exist, regardless of $_message
227 $_type = $result ?
'success' : 'error';
228 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
229 $extra_data['sql_query'] = PMA_showMessage(null, $sql_query);
230 PMA_ajaxResponse($_message, $_message->isSuccess(), $extra_data);
233 if (! empty($warning_messages)) {
234 $_message = new PMA_Message
;
235 $_message->addMessages($warning_messages);
236 $_message->isError(true);
237 if ( $_REQUEST['ajax_request'] == true) {
238 PMA_ajaxResponse($_message, false);
240 unset($warning_messages);
243 PMA_showMessage($_message, $sql_query, $_type);
244 unset($_message, $_type);
247 $url_params['goto'] =
248 $url_params['back'] = 'tbl_operations.php';
253 $columns = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']);
259 <!-- Order the table
-->
260 <div
class="operations_half_width">
261 <form method
="post" id
="alterTableOrderby" action
="tbl_operations.php" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
262 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
263 <fieldset id
="fieldset_table_order">
264 <legend
><?php
echo __('Alter table order by'); ?
></legend
>
265 <select name
="order_field">
267 foreach ($columns as $fieldname) {
268 echo ' <option value="' . htmlspecialchars($fieldname['Field']) . '">'
269 . htmlspecialchars($fieldname['Field']) . '</option>' . "\n";
273 </select
> <?php
echo __('(singly)'); ?
>
274 <select name
="order_order">
275 <option value
="asc"><?php
echo __('Ascending'); ?
></option
>
276 <option value
="desc"><?php
echo __('Descending'); ?
></option
>
279 <fieldset
class="tblFooters">
280 <input type
="submit" name
="submitorderby" value
="<?php echo __('Go'); ?>" />
286 <div
class="operations_half_width">
287 <form method
="post" action
="tbl_operations.php"
288 onsubmit
="return emptyFormElements(this, 'new_name')">
289 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
290 <input type
="hidden" name
="reload" value
="1" />
291 <input type
="hidden" name
="what" value
="data" />
292 <fieldset id
="fieldset_table_rename">
293 <legend
><?php
echo __('Move table to (database<b>.</b>table):'); ?
></legend
>
294 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
296 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
300 <select name
="target_db">
301 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
306  
;<strong
>.</strong
> 
;
307 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
308 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br
/>
310 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
311 // next value but users can decide if they want it or not for the operation
313 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_mv" checked
="checked" />
314 <label
for="checkbox_auto_increment_mv"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
316 <fieldset
class="tblFooters">
317 <input type
="submit" name
="submit_move" value
="<?php echo __('Go'); ?>" />
323 if (strstr($show_comment, '; InnoDB free') === false) {
324 if (strstr($show_comment, 'InnoDB free') === false) {
325 // only user entered comment
326 $comment = $show_comment;
328 // here we have just InnoDB generated part
332 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
333 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
336 // PACK_KEYS: MyISAM or ISAM
337 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
338 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
340 // Here should be version check for InnoDB, however it is supported
341 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
345 <!-- Table options
-->
346 <div
class="operations_half_width clearfloat">
347 <form method
="post" action
="tbl_operations.php">
348 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
349 <input type
="hidden" name
="reload" value
="1" />
351 <legend
><?php
echo __('Table options'); ?
></legend
>
354 <!-- Change table name
-->
355 <tr
><td
><?php
echo __('Rename table to'); ?
></td
>
356 <td
><input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
357 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
361 <!-- Table comments
-->
362 <tr
><td
><?php
echo __('Table comments'); ?
></td
>
363 <td
><input type
="text" name
="comment" maxlength
="60" size
="30"
364 value
="<?php echo htmlspecialchars($comment); ?>" onfocus
="this.select()" />
365 <input type
="hidden" name
="prev_comment" value
="<?php echo htmlspecialchars($comment); ?>" />
369 <!-- Storage engine
-->
370 <tr
><td
><?php
echo __('Storage Engine'); ?
>
371 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
373 <td
><?php
echo PMA_StorageEngine
::getHtmlSelect('new_tbl_storage_engine', null, $tbl_storage_engine); ?
>
377 <!-- Table character set
-->
378 <tr
><td
><?php
echo __('Collation'); ?
></td
>
379 <td
><?php
echo PMA_generateCharsetDropdownBox(
380 PMA_CSDROPDOWN_COLLATION
,
381 'tbl_collation', null, $tbl_collation, false, 3
386 if ($is_myisam_or_aria ||
$is_isam) {
389 <td
><label
for="new_pack_keys">PACK_KEYS
</label
></td
>
390 <td
><select name
="new_pack_keys" id
="new_pack_keys">
391 <option value
="DEFAULT"
392 <?php
if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?
>
395 <?php
if ($pack_keys == '0') echo 'selected="selected"'; ?
>
398 <?php
if ($pack_keys == '1') echo 'selected="selected"'; ?
>
404 } // end if (MYISAM|ISAM)
406 if ($is_myisam_or_aria) {
408 <tr
><td
><label
for="new_checksum">CHECKSUM
</label
></td
>
409 <td
><input type
="checkbox" name
="new_checksum" id
="new_checksum"
411 <?php
echo (isset($checksum) && $checksum == 1)
412 ?
' checked="checked"'
417 <tr
><td
><label
for="new_delay_key_write">DELAY_KEY_WRITE
</label
></td
>
418 <td
><input type
="checkbox" name
="new_delay_key_write" id
="new_delay_key_write"
420 <?php
echo (isset($delay_key_write) && $delay_key_write == 1)
421 ?
' checked="checked"'
431 <tr
><td
><label
for="new_transactional">TRANSACTIONAL
</label
></td
>
432 <td
><input type
="checkbox" name
="new_transactional" id
="new_transactional"
434 <?php
echo (isset($transactional) && $transactional == 1)
435 ?
' checked="checked"'
440 <tr
><td
><label
for="new_page_checksum">PAGE_CHECKSUM
</label
></td
>
441 <td
><input type
="checkbox" name
="new_page_checksum" id
="new_page_checksum"
443 <?php
echo (isset($page_checksum) && $page_checksum == 1)
444 ?
' checked="checked"'
452 if (isset($auto_increment) && strlen($auto_increment) > 0
453 && ($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)) {
455 <tr
><td
><label
for="auto_increment_opt">AUTO_INCREMENT
</label
></td
>
456 <td
><input type
="text" name
="new_auto_increment" id
="auto_increment_opt"
457 value
="<?php echo $auto_increment; ?>" /></td
>
460 } // end if (MYISAM|INNODB)
462 // the outer array is for engines, the inner array contains the dropdown
463 // option values as keys then the dropdown option labels
465 $possible_row_formats = array(
468 'DYNAMIC' => 'DYNAMIC',
473 'DYNAMIC' => 'DYNAMIC',
478 'DYNAMIC' => 'DYNAMIC'
482 'DYNAMIC' => 'DYNAMIC'
485 'COMPACT' => 'COMPACT',
486 'REDUNDANT' => 'REDUNDANT')
489 $innodb_engine_plugin = PMA_StorageEngine
::getEngine('innodb');
490 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
491 if (!empty($innodb_plugin_version)) {
492 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
494 $innodb_file_format = '';
496 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
497 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
498 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
500 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
502 // for MYISAM there is also COMPRESSED but it can be set only by the
503 // myisampack utility, so don't offer here the choice because if we
504 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
505 // does not return a warning
506 // (if the table was compressed, it can be seen on the Structure page)
508 if (isset($possible_row_formats[$tbl_storage_engine])) {
509 $current_row_format = strtoupper($showtable['Row_format']);
510 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
512 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format');
513 unset($possible_row_formats, $current_row_format);
520 <fieldset
class="tblFooters">
521 <input type
="submit" name
="submitoptions" value
="<?php echo __('Go'); ?>" />
527 <div
class="operations_half_width">
528 <form method
="post" action
="tbl_operations.php" name
="copyTable" id
="copyTable" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>
529 onsubmit
="return emptyFormElements(this, 'new_name')">
530 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
531 <input type
="hidden" name
="reload" value
="1" />
533 <legend
><?php
echo __('Copy table to (database<b>.</b>table):'); ?
></legend
>
534 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
536 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
540 <select name
="target_db">
541 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
546  
;<strong
>.</strong
> 
;
547 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()" value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br
/>
550 'structure' => __('Structure only'),
551 'data' => __('Structure and data'),
552 'dataonly' => __('Data only'));
553 PMA_display_html_radio('what', $choices, 'data', true);
557 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
558 <label
for="checkbox_drop"><?php
echo sprintf(__('Add %s'), 'DROP TABLE'); ?
></label
><br
/>
559 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_cp" />
560 <label
for="checkbox_auto_increment_cp"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
562 // display "Add constraints" choice only if there are
564 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
566 <input type
="checkbox" name
="add_constraints" value
="1" id
="checkbox_constraints" />
567 <label
for="checkbox_constraints"><?php
echo __('Add constraints'); ?
></label
><br
/>
570 if (isset($_COOKIE['pma_switch_to_new'])
571 && $_COOKIE['pma_switch_to_new'] == 'true') {
572 $pma_switch_to_new = 'true';
575 <input type
="checkbox" name
="switch_to_new" value
="true"
576 id
="checkbox_switch"<?php
echo
577 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
578 ?
' checked="checked"'
580 <label
for="checkbox_switch"><?php
echo __('Switch to copied table'); ?
></label
>
582 <fieldset
class="tblFooters">
583 <input type
="submit" name
="submit_copy" value
="<?php echo __('Go'); ?>" />
588 <br
class="clearfloat"/>
590 <div
class="operations_half_width">
592 <legend
><?php
echo __('Table maintenance'); ?
></legend
>
594 <ul id
="tbl_maintenance" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
596 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
597 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
598 if ($is_myisam_or_aria ||
$is_innodb) {
599 $this_url_params = array_merge(
602 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']),
603 'table_maintenance' => 'Go',
607 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
608 <?php
echo __('Check table'); ?
></a
>
609 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?
>
614 $this_url_params = array_merge(
616 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB')
619 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
620 <?php
echo __('Defragment table'); ?
></a
>
621 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?
>
625 if ($is_myisam_or_aria ||
$is_berkeleydb) {
626 $this_url_params = array_merge(
629 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
630 'table_maintenance' => 'Go',
634 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
635 <?php
echo __('Analyze table'); ?
></a
>
636 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?
>
640 if ($is_myisam_or_aria && !PMA_DRIZZLE
) {
641 $this_url_params = array_merge(
644 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
645 'table_maintenance' => 'Go',
649 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
650 <?php
echo __('Repair table'); ?
></a
>
651 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?
>
655 if (($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) && !PMA_DRIZZLE
) {
656 $this_url_params = array_merge(
659 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
660 'table_maintenance' => 'Go',
664 <li
><a
class='maintain_action' href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
665 <?php
echo __('Optimize table'); ?
></a
>
666 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?
>
670 } // end MYISAM or BERKELEYDB case
671 $this_url_params = array_merge(
674 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
675 'message_to_show' => sprintf(
676 __('Table %s has been flushed'),
677 htmlspecialchars($GLOBALS['table'])
683 <li
><a
class='maintain_action' href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
684 <?php
echo __('Flush the table (FLUSH)'); ?
></a
>
685 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?
>
690 <?php
if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?
>
691 <div
class="operations_half_width">
692 <fieldset
class="caution">
693 <legend
><?php
echo __('Delete data or table'); ?
></legend
>
697 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
698 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
699 $this_url_params = array_merge(
702 'sql_query' => $this_sql_query,
703 'goto' => 'tbl_structure.php',
705 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
709 <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"' : ''); ?
>>
710 <?php
echo __('Empty the table (TRUNCATE)'); ?
></a
>
711 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?
>
715 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
716 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
717 $this_url_params = array_merge(
720 'sql_query' => $this_sql_query,
721 'goto' => 'db_operations.php',
724 'message_to_show' => sprintf(($tbl_is_view ?
__('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
725 // table name is needed to avoid running
726 // PMA_relationsCleanupDatabase() on the whole db later
727 'table' => $GLOBALS['table'],
731 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
'id="drop_tbl_anchor"' : ''); ?
>>
732 <?php
echo __('Delete the table (DROP)'); ?
></a
>
733 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?
>
744 <br
class="clearfloat">
745 <?php
if (PMA_Partition
::havePartitioning()) {
746 $partition_names = PMA_Partition
::getPartitionNames($db, $table);
747 // show the Partition maintenance section only if we detect a partition
748 if (! is_null($partition_names[0])) {
750 <div
class="operations_half_width">
751 <form method
="post" action
="tbl_operations.php">
752 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
754 <legend
><?php
echo __('Partition maintenance'); ?
></legend
>
756 $html_select = '<select name="partition_name">' . "\n";
757 foreach ($partition_names as $one_partition) {
758 $one_partition = htmlspecialchars($one_partition);
759 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
761 $html_select .= '</select>' . "\n";
762 printf(__('Partition %s'), $html_select);
763 unset($partition_names, $one_partition, $html_select);
765 'ANALYZE' => __('Analyze'),
766 'CHECK' => __('Check'),
767 'OPTIMIZE' => __('Optimize'),
768 'REBUILD' => __('Rebuild'),
769 'REPAIR' => __('Repair'));
770 PMA_display_html_radio('partition_operation', $choices, '', false);
772 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
773 // I'm not sure of the best way to display that; this link does
774 // not depend on the Go button
775 $this_url_params = array_merge(
778 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
782 <br
/><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
783 <?php
echo __('Remove partitioning'); ?
></a
>
785 <fieldset
class="tblFooters">
786 <input type
="submit" name
="submit_partition" value
="<?php echo __('Go'); ?>" />
794 // Referential integrity check
795 // The Referential integrity check was intended for the non-InnoDB
796 // tables for which the relations are defined in pmadb
797 // so I assume that if the current table is InnoDB, I don't display
798 // this choice (InnoDB maintains integrity by itself)
800 if ($cfgRelation['relwork'] && ! $is_innodb) {
801 PMA_DBI_select_db($GLOBALS['db']);
802 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
806 <!-- Referential integrity check
-->
807 <div
class="operations_half_width">
809 <legend
><?php
echo __('Check referential integrity:'); ?
></legend
>
813 foreach ($foreign AS $master => $arr) {
814 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
815 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
816 . PMA_backquote($arr['foreign_table']);
817 if ($arr['foreign_table'] == $GLOBALS['table']) {
818 $foreign_table = $GLOBALS['table'] . '1';
819 $join_query .= ' AS ' . PMA_backquote($foreign_table);
821 $foreign_table = $arr['foreign_table'];
823 $join_query .= ' ON '
824 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
825 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
827 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
829 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
831 $this_url_params = array_merge(
833 array('sql_query' => $join_query)
837 . PMA_generate_common_url($this_url_params)
838 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
839 . '</a></li>' . "\n";
840 } // foreach $foreign
841 unset($foreign_table, $join_query);
847 } // end if ($foreign)
849 } // end if (!empty($cfg['Server']['relation']))
853 * Displays the footer
855 require 'libraries/footer.inc.php';
858 function PMA_set_global_variables_for_engine($tbl_storage_engine)
860 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
862 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
863 $upper_tbl_storage_engine = strtoupper($tbl_storage_engine);
865 //Options that apply to MYISAM usually apply to ARIA
866 $is_myisam_or_aria = ($upper_tbl_storage_engine == 'MYISAM' ||
$upper_tbl_storage_engine == 'ARIA' ||
$upper_tbl_storage_engine == 'MARIA');
867 $is_aria = ($upper_tbl_storage_engine == 'ARIA');
869 $is_isam = ($upper_tbl_storage_engine == 'ISAM');
870 $is_innodb = ($upper_tbl_storage_engine == 'INNODB');
871 $is_berkeleydb = ($upper_tbl_storage_engine == 'BERKELEYDB');
872 $is_pbxt = ($upper_tbl_storage_engine == 'PBXT');