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_type);
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 require_once './tbl_move_copy.php';
74 * If the table has to be maintained
76 if(isset($_REQUEST['table_maintenance'])) {
77 require_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_type'])
104 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
105 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
106 $tbl_type = $_REQUEST['new_tbl_type'];
107 // reset the globals for the new engine
108 PMA_set_global_variables_for_engine($tbl_type);
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_type'] == '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 require './libraries/tbl_info.inc.php';
215 * Displays top menu links
217 require_once './libraries/tbl_links.inc.php';
219 if (isset($result) && empty($message_to_show)) {
220 // set to success by default, because result set could be empty
221 // (for example, a table rename)
223 if (empty($_message)) {
224 $_message = $result ?
__('Your SQL query has been executed successfully') : __('Error');
225 // $result should exist, regardless of $_message
226 $_type = $result ?
'success' : 'error';
228 if (! empty($warning_messages)) {
229 $_message = new PMA_Message
;
230 $_message->addMessages($warning_messages);
231 $_message->isWarning(true);
232 unset($warning_messages);
234 PMA_showMessage($_message, $sql_query, $_type);
235 unset($_message, $_type);
238 $url_params['goto'] = 'tbl_operations.php';
239 $url_params['back'] = 'tbl_operations.php';
246 FROM ' . PMA_backquote($GLOBALS['table']) . '
247 FROM ' . PMA_backquote($GLOBALS['db']);
248 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
255 <!-- Order the table
-->
256 <div id
="div_table_order">
257 <form method
="post" action
="tbl_operations.php">
258 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
259 <fieldset id
="fieldset_table_order">
260 <legend
><?php
echo __('Alter table order by'); ?
></legend
>
261 <select name
="order_field">
263 foreach ($columns as $fieldname) {
264 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
265 . htmlspecialchars($fieldname) . '</option>' . "\n";
269 </select
> <?php
echo __('(singly)'); ?
>
270 <select name
="order_order">
271 <option value
="asc"><?php
echo __('Ascending'); ?
></option
>
272 <option value
="desc"><?php
echo __('Descending'); ?
></option
>
275 <fieldset
class="tblFooters">
276 <input type
="submit" name
="submitorderby" value
="<?php echo __('Go'); ?>" />
282 <div id
="div_table_rename">
283 <form method
="post" action
="tbl_operations.php"
284 onsubmit
="return emptyFormElements(this, 'new_name')">
285 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
286 <input type
="hidden" name
="reload" value
="1" />
287 <input type
="hidden" name
="what" value
="data" />
288 <fieldset id
="fieldset_table_rename">
289 <legend
><?php
echo __('Move table to (database<b>.</b>table):'); ?
></legend
>
290 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
292 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
296 <select name
="target_db">
297 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
302  
;<strong
>.</strong
> 
;
303 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
304 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br
/>
306 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
307 // next value but users can decide if they want it or not for the operation
309 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_mv" checked
="checked" />
310 <label
for="checkbox_auto_increment_mv"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
312 <fieldset
class="tblFooters">
313 <input type
="submit" name
="submit_move" value
="<?php echo __('Go'); ?>" />
319 if (strstr($show_comment, '; InnoDB free') === false) {
320 if (strstr($show_comment, 'InnoDB free') === false) {
321 // only user entered comment
322 $comment = $show_comment;
324 // here we have just InnoDB generated part
328 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
329 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
332 // PACK_KEYS: MyISAM or ISAM
333 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
334 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
336 // Here should be version check for InnoDB, however it is supported
337 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
341 <!-- Table options
-->
342 <div id
="div_table_options">
343 <form method
="post" action
="tbl_operations.php">
344 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
345 <input type
="hidden" name
="reload" value
="1" />
347 <legend
><?php
echo __('Table options'); ?
></legend
>
350 <!-- Change table name
-->
351 <tr
><td
><?php
echo __('Rename table to'); ?
></td
>
352 <td
><input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
353 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
357 <!-- Table comments
-->
358 <tr
><td
><?php
echo __('Table comments'); ?
></td
>
359 <td
><input type
="text" name
="comment" maxlength
="60" size
="30"
360 value
="<?php echo htmlspecialchars($comment); ?>" onfocus
="this.select()" />
361 <input type
="hidden" name
="prev_comment" value
="<?php echo htmlspecialchars($comment); ?>" />
365 <!-- Storage engine
-->
366 <tr
><td
><?php
echo __('Storage Engine'); ?
>
367 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
369 <td
><?php
echo PMA_StorageEngine
::getHtmlSelect('new_tbl_type', null, $tbl_type); ?
>
373 <!-- Table character set
-->
374 <tr
><td
><?php
echo __('Collation'); ?
></td
>
375 <td
><?php
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
,
376 'tbl_collation', null, $tbl_collation, false, 3); ?
>
380 if ($is_myisam_or_aria ||
$is_isam) {
383 <td
><label
for="new_pack_keys">PACK_KEYS
</label
></td
>
384 <td
><select name
="new_pack_keys" id
="new_pack_keys">
385 <option value
="DEFAULT"
386 <?php
if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?
>
389 <?php
if ($pack_keys == '0') echo 'selected="selected"'; ?
>
392 <?php
if ($pack_keys == '1') echo 'selected="selected"'; ?
>
398 } // end if (MYISAM|ISAM)
400 if ($is_myisam_or_aria) {
402 <tr
><td
><label
for="new_checksum">CHECKSUM
</label
></td
>
403 <td
><input type
="checkbox" name
="new_checksum" id
="new_checksum"
405 <?php
echo (isset($checksum) && $checksum == 1)
406 ?
' checked="checked"'
411 <tr
><td
><label
for="new_delay_key_write">DELAY_KEY_WRITE
</label
></td
>
412 <td
><input type
="checkbox" name
="new_delay_key_write" id
="new_delay_key_write"
414 <?php
echo (isset($delay_key_write) && $delay_key_write == 1)
415 ?
' checked="checked"'
425 <tr
><td
><label
for="new_transactional">TRANSACTIONAL
</label
></td
>
426 <td
><input type
="checkbox" name
="new_transactional" id
="new_transactional"
428 <?php
echo (isset($transactional) && $transactional == 1)
429 ?
' checked="checked"'
434 <tr
><td
><label
for="new_page_checksum">PAGE_CHECKSUM
</label
></td
>
435 <td
><input type
="checkbox" name
="new_page_checksum" id
="new_page_checksum"
437 <?php
echo (isset($page_checksum) && $page_checksum == 1)
438 ?
' checked="checked"'
446 if (isset($auto_increment) && strlen($auto_increment) > 0
447 && ($is_myisam_or_aria ||
$is_innodb ||
$is_pbxt)) {
449 <tr
><td
><label
for="auto_increment_opt">AUTO_INCREMENT
</label
></td
>
450 <td
><input type
="text" name
="new_auto_increment" id
="auto_increment_opt"
451 value
="<?php echo $auto_increment; ?>" /></td
>
454 } // end if (MYISAM|INNODB)
456 // the outer array is for engines, the inner array contains the dropdown
457 // option values as keys then the dropdown option labels
459 $possible_row_formats = array(
462 'DYNAMIC' => 'DYNAMIC',
467 'DYNAMIC' => 'DYNAMIC',
472 'DYNAMIC' => 'DYNAMIC'
476 'DYNAMIC' => 'DYNAMIC'
479 'COMPACT' => 'COMPACT',
480 'REDUNDANT' => 'REDUNDANT')
483 $innodb_engine_plugin = PMA_StorageEngine
::getEngine('innodb');
484 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
485 if (!empty($innodb_plugin_version)) {
486 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
488 $innodb_file_format = '';
490 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
491 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
492 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
494 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
496 // for MYISAM there is also COMPRESSED but it can be set only by the
497 // myisampack utility, so don't offer here the choice because if we
498 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
499 // does not return a warning
500 // (if the table was compressed, it can be seen on the Structure page)
502 if (isset($possible_row_formats[$tbl_type])) {
503 $current_row_format = strtoupper($showtable['Row_format']);
504 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
506 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
507 unset($possible_row_formats, $current_row_format);
514 <fieldset
class="tblFooters">
515 <input type
="submit" name
="submitoptions" value
="<?php echo __('Go'); ?>" />
521 <div id
="div_table_copy">
522 <form method
="post" action
="tbl_operations.php"
523 onsubmit
="return emptyFormElements(this, 'new_name')">
524 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
525 <input type
="hidden" name
="reload" value
="1" />
527 <legend
><?php
echo __('Copy table to (database<b>.</b>table):'); ?
></legend
>
528 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
530 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
534 <select name
="target_db">
535 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
540  
;<strong
>.</strong
> 
;
541 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()" value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br
/>
544 'structure' => __('Structure only'),
545 'data' => __('Structure and data'),
546 'dataonly' => __('Data only'));
547 PMA_display_html_radio('what', $choices, 'data', true);
551 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
552 <label
for="checkbox_drop"><?php
echo sprintf(__('Add %s'), 'DROP TABLE'); ?
></label
><br
/>
553 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_cp" />
554 <label
for="checkbox_auto_increment_cp"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
556 // display "Add constraints" choice only if there are
558 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
560 <input type
="checkbox" name
="add_constraints" value
="1" id
="checkbox_constraints" />
561 <label
for="checkbox_constraints"><?php
echo __('Add constraints'); ?
></label
><br
/>
564 if (isset($_COOKIE['pma_switch_to_new'])
565 && $_COOKIE['pma_switch_to_new'] == 'true') {
566 $pma_switch_to_new = 'true';
569 <input type
="checkbox" name
="switch_to_new" value
="true"
570 id
="checkbox_switch"<?php
echo
571 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
572 ?
' checked="checked"'
574 <label
for="checkbox_switch"><?php
echo __('Switch to copied table'); ?
></label
>
576 <fieldset
class="tblFooters">
577 <input type
="submit" name
="submit_copy" value
="<?php echo __('Go'); ?>" />
582 <br
class="clearfloat"/>
584 <div id
="div_table_maintenance">
586 <legend
><?php
echo __('Table maintenance'); ?
></legend
>
590 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
591 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
592 if ($is_myisam_or_aria ||
$is_innodb) {
593 $this_url_params = array_merge($url_params,
595 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']),
596 'table_maintenance' => 'Go',
599 <li
><a href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
600 <?php
echo __('Check table'); ?
></a
>
601 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?
>
606 $this_url_params = array_merge($url_params,
607 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
609 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
610 <?php
echo __('Defragment table'); ?
></a
>
611 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?
>
615 if ($is_myisam_or_aria ||
$is_berkeleydb) {
616 $this_url_params = array_merge($url_params,
618 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
619 'table_maintenance' => 'Go',
622 <li
><a href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
623 <?php
echo __('Analyze table'); ?
></a
>
624 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?
>
628 if ($is_myisam_or_aria) {
629 $this_url_params = array_merge($url_params,
631 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
632 'table_maintenance' => 'Go',
635 <li
><a href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
636 <?php
echo __('Repair table'); ?
></a
>
637 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?
>
641 if ($is_myisam_or_aria ||
$is_innodb ||
$is_berkeleydb) {
642 $this_url_params = array_merge($url_params,
644 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
645 'table_maintenance' => 'Go',
648 <li
><a href
="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
649 <?php
echo __('Optimize table'); ?
></a
>
650 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?
>
654 } // end MYISAM or BERKELEYDB case
655 $this_url_params = array_merge($url_params,
657 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
658 'message_to_show' => sprintf(__('Table %s has been flushed'),
659 htmlspecialchars($GLOBALS['table'])),
663 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
664 <?php
echo __('Flush the table (FLUSH)'); ?
></a
>
665 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?
>
670 <?php
if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?
>
671 <div id
="div_table_removal">
672 <fieldset
class="caution">
673 <legend
><?php
echo __('Delete data or table'); ?
></legend
>
677 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
678 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
679 $this_url_params = array_merge($url_params,
681 'sql_query' => $this_sql_query,
682 'goto' => 'tbl_structure.php',
684 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
687 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick
="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
688 <?php
echo __('Empty the table (TRUNCATE)'); ?
></a
>
689 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?
>
693 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
694 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
695 $this_url_params = array_merge($url_params,
697 'sql_query' => $this_sql_query,
698 'goto' => 'db_operations.php',
701 'message_to_show' => sprintf(($tbl_is_view ?
__('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
702 // table name is needed to avoid running
703 // PMA_relationsCleanupDatabase() on the whole db later
704 'table' => $GLOBALS['table'],
707 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick
="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
708 <?php
echo __('Delete the table (DROP)'); ?
></a
>
709 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?
>
720 <?php
if (PMA_Partition
::havePartitioning()) {
721 $partition_names = PMA_Partition
::getPartitionNames($db, $table);
722 // show the Partition maintenance section only if we detect a partition
723 if (! is_null($partition_names[0])) {
725 <div id
="div_partition_maintenance">
726 <form method
="post" action
="tbl_operations.php">
727 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
729 <legend
><?php
echo __('Partition maintenance'); ?
></legend
>
731 $html_select = '<select name="partition_name">' . "\n";
732 foreach($partition_names as $one_partition) {
733 $one_partition = htmlspecialchars($one_partition);
734 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
736 $html_select .= '</select>' . "\n";
737 printf(__('Partition %s'), $html_select);
738 unset($partition_names, $one_partition, $html_select);
740 'ANALYZE' => __('Analyze'),
741 'CHECK' => __('Check'),
742 'OPTIMIZE' => __('Optimize'),
743 'REBUILD' => __('Rebuild'),
744 'REPAIR' => __('Repair'));
745 PMA_display_html_radio('partition_operation', $choices, '', false);
747 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
748 // I'm not sure of the best way to display that; this link does
749 // not depend on the Go button
750 $this_url_params = array_merge($url_params,
752 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
755 <br
/><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
756 <?php
echo __('Remove partitioning'); ?
></a
>
758 <fieldset
class="tblFooters">
759 <input type
="submit" name
="submit_partition" value
="<?php echo __('Go'); ?>" />
767 // Referential integrity check
768 // The Referential integrity check was intended for the non-InnoDB
769 // tables for which the relations are defined in pmadb
770 // so I assume that if the current table is InnoDB, I don't display
771 // this choice (InnoDB maintains integrity by itself)
773 if ($cfgRelation['relwork'] && ! $is_innodb) {
774 PMA_DBI_select_db($GLOBALS['db']);
775 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
779 <!-- Referential integrity check
-->
780 <div id
="div_referential_integrity">
782 <legend
><?php
echo __('Check referential integrity:'); ?
></legend
>
786 foreach ($foreign AS $master => $arr) {
787 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
788 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
789 . PMA_backquote($arr['foreign_table']);
790 if ($arr['foreign_table'] == $GLOBALS['table']) {
791 $foreign_table = $GLOBALS['table'] . '1';
792 $join_query .= ' AS ' . PMA_backquote($foreign_table);
794 $foreign_table = $arr['foreign_table'];
796 $join_query .= ' ON '
797 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
798 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
800 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
802 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
804 $this_url_params = array_merge($url_params,
805 array('sql_query' => $join_query));
808 . PMA_generate_common_url($this_url_params)
809 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
810 . '</a></li>' . "\n";
811 } // foreach $foreign
812 unset($foreign_table, $join_query);
818 } // end if ($foreign)
820 } // end if (!empty($cfg['Server']['relation']))
824 * Displays the footer
826 require './libraries/footer.inc.php';
829 function PMA_set_global_variables_for_engine($tbl_type)
831 global $is_myisam_or_aria, $is_innodb, $is_isam, $is_berkeleydb, $is_aria, $is_pbxt;
833 $is_myisam_or_aria = $is_isam = $is_innodb = $is_berkeleydb = $is_aria = $is_pbxt = false;
834 $upper_tbl_type = strtoupper($tbl_type);
836 //Options that apply to MYISAM usually apply to ARIA
837 $is_myisam_or_aria = ($upper_tbl_type == 'MYISAM' ||
$upper_tbl_type == 'ARIA' ||
$upper_tbl_type == 'MARIA');
838 $is_aria = ($upper_tbl_type == 'ARIA');
840 $is_isam = ($upper_tbl_type == 'ISAM');
841 $is_innodb = ($upper_tbl_type == 'INNODB');
842 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
843 $is_pbxt = ($upper_tbl_type == 'PBXT');