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_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $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 * Updates table comment, type and options if required
69 if (isset($_REQUEST['submitoptions'])) {
71 $warning_messages = array();
73 if (isset($_REQUEST['new_name'])) {
74 if ($pma_table->rename($_REQUEST['new_name'])) {
75 $_message .= $pma_table->getLastMessage();
77 $GLOBALS['table'] = $pma_table->getName();
81 $_message .= $pma_table->getLastError();
85 if (isset($_REQUEST['comment'])
86 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
87 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
89 if (! empty($_REQUEST['new_tbl_type'])
90 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
91 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
92 $tbl_type = $_REQUEST['new_tbl_type'];
93 // reset the globals for the new engine
94 PMA_set_global_variables_for_engine($tbl_type);
96 $transactional = (isset($transactional) && $transactional == '0') ?
'0' : '1';
97 $page_checksum = (isset($page_checksum)) ?
$page_checksum : '';
101 if (! empty($_REQUEST['tbl_collation'])
102 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
103 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
106 if (($is_myisam_or_maria ||
$is_isam)
107 && isset($_REQUEST['new_pack_keys'])
108 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
109 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
112 $checksum = empty($checksum) ?
'0' : '1';
113 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ?
'0' : '1';
114 if ($is_myisam_or_maria
115 && $_REQUEST['new_checksum'] !== $checksum) {
116 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
119 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ?
'0' : '1';
121 && $_REQUEST['new_transactional'] !== $transactional) {
122 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
125 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ?
'0' : '1';
127 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
128 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
131 $delay_key_write = empty($delay_key_write) ?
'0' : '1';
132 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ?
'0' : '1';
133 if ($is_myisam_or_maria
134 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
135 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
138 if (($is_myisam_or_maria ||
$is_innodb ||
$is_pbxt)
139 && ! empty($_REQUEST['new_auto_increment'])
140 && (! isset($auto_increment) ||
$_REQUEST['new_auto_increment'] !== $auto_increment)) {
141 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
144 if (($is_myisam_or_maria ||
$is_innodb ||
$is_pbxt)
145 && ! empty($_REQUEST['new_row_format'])
146 && (! isset($row_format) ||
strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
147 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
150 if (count($table_alters) > 0) {
151 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
152 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
153 $result .= PMA_DBI_query($sql_query) ?
true : false;
155 unset($table_alters);
156 foreach (PMA_DBI_get_warnings() as $warning) {
157 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
158 // and if TRANSACTIONAL was set, the system reports an error;
159 // I discussed with a Maria developer and he agrees that this
160 // should not be reported with a Level of Error, so here
161 // I just ignore it. But there are other 1478 messages
162 // that it's better to show.
163 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
164 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
165 . ' ' . $warning['Message'];
171 * Reordering the table has been requested by the user
173 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
175 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
176 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
177 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
178 $sql_query .= ' DESC';
180 $result = PMA_DBI_query($sql_query);
184 * A partition operation has been requested by the user
186 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
187 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
188 $result = PMA_DBI_query($sql_query);
192 // to avoid showing the old value (for example the AUTO_INCREMENT) after
193 // a change, clear the cache
194 PMA_Table
::$cache = array();
195 $page_checksum = $checksum = $delay_key_write = 0;
196 require './libraries/tbl_info.inc.php';
201 * Displays top menu links
203 require_once './libraries/tbl_links.inc.php';
205 if (isset($result) && empty($zero_rows)) {
206 // set to success by default, because result set could be empty
207 // (for example, a table rename)
209 if (empty($_message)) {
210 $_message = $result ?
__('Your SQL query has been executed successfully') : __('Error');
211 // $result should exist, regardless of $_message
212 $_type = $result ?
'success' : 'error';
214 if (! empty($warning_messages)) {
215 $_message = new PMA_Message
;
216 $_message->addMessages($warning_messages);
217 $_message->isWarning(true);
218 unset($warning_messages);
220 PMA_showMessage($_message, $sql_query, $_type);
221 unset($_message, $_type);
224 $url_params['goto'] = 'tbl_operations.php';
225 $url_params['back'] = 'tbl_operations.php';
232 FROM ' . PMA_backquote($GLOBALS['table']) . '
233 FROM ' . PMA_backquote($GLOBALS['db']);
234 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
241 <!-- Order the table
-->
242 <div id
="div_table_order">
243 <form method
="post" action
="tbl_operations.php">
244 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
245 <fieldset id
="fieldset_table_order">
246 <legend
><?php
echo __('Alter table order by'); ?
></legend
>
247 <select name
="order_field">
249 foreach ($columns as $fieldname) {
250 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
251 . htmlspecialchars($fieldname) . '</option>' . "\n";
255 </select
> <?php
echo __('(singly)'); ?
>
256 <select name
="order_order">
257 <option value
="asc"><?php
echo __('Ascending'); ?
></option
>
258 <option value
="desc"><?php
echo __('Descending'); ?
></option
>
261 <fieldset
class="tblFooters">
262 <input type
="submit" name
="submitorderby" value
="<?php echo __('Go'); ?>" />
268 <div id
="div_table_rename">
269 <form method
="post" action
="tbl_move_copy.php"
270 onsubmit
="return emptyFormElements(this, 'new_name')">
271 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
272 <input type
="hidden" name
="reload" value
="1" />
273 <input type
="hidden" name
="what" value
="data" />
274 <fieldset id
="fieldset_table_rename">
275 <legend
><?php
echo __('Move table to (database<b>.</b>table):'); ?
></legend
>
276 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
278 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
282 <select name
="target_db">
283 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
288  
;<strong
>.</strong
> 
;
289 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
290 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br
/>
292 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
293 // next value but users can decide if they want it or not for the operation
295 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_mv" checked
="checked" />
296 <label
for="checkbox_auto_increment_mv"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
298 <fieldset
class="tblFooters">
299 <input type
="submit" name
="submit_move" value
="<?php echo __('Go'); ?>" />
305 if (strstr($show_comment, '; InnoDB free') === false) {
306 if (strstr($show_comment, 'InnoDB free') === false) {
307 // only user entered comment
308 $comment = $show_comment;
310 // here we have just InnoDB generated part
314 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
315 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
318 // PACK_KEYS: MyISAM or ISAM
319 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
320 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
322 // Here should be version check for InnoDB, however it is supported
323 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
327 <!-- Table options
-->
328 <div id
="div_table_options">
329 <form method
="post" action
="tbl_operations.php">
330 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
331 <input type
="hidden" name
="reload" value
="1" />
333 <legend
><?php
echo __('Table options'); ?
></legend
>
336 <!-- Change table name
-->
337 <tr
><td
><?php
echo __('Rename table to'); ?
></td
>
338 <td
><input type
="text" size
="20" name
="new_name" onfocus
="this.select()"
339 value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
343 <!-- Table comments
-->
344 <tr
><td
><?php
echo __('Table comments'); ?
></td
>
345 <td
><input type
="text" name
="comment" maxlength
="60" size
="30"
346 value
="<?php echo htmlspecialchars($comment); ?>" onfocus
="this.select()" />
347 <input type
="hidden" name
="prev_comment" value
="<?php echo htmlspecialchars($comment); ?>" />
351 <!-- Storage engine
-->
352 <tr
><td
><?php
echo __('Storage Engine'); ?
>
353 <?php
echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?
>
355 <td
><?php
echo PMA_StorageEngine
::getHtmlSelect('new_tbl_type', null, $tbl_type); ?
>
359 <!-- Table character set
-->
360 <tr
><td
><?php
echo __('Collation'); ?
></td
>
361 <td
><?php
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
,
362 'tbl_collation', null, $tbl_collation, false, 3); ?
>
366 if ($is_myisam_or_maria ||
$is_isam) {
369 <td
><label
for="new_pack_keys">PACK_KEYS
</label
></td
>
370 <td
><select name
="new_pack_keys" id
="new_pack_keys">
371 <option value
="DEFAULT"
372 <?php
if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?
>
375 <?php
if ($pack_keys == '0') echo 'selected="selected"'; ?
>
378 <?php
if ($pack_keys == '1') echo 'selected="selected"'; ?
>
384 } // end if (MYISAM|ISAM)
386 if ($is_myisam_or_maria) {
388 <tr
><td
><label
for="new_checksum">CHECKSUM
</label
></td
>
389 <td
><input type
="checkbox" name
="new_checksum" id
="new_checksum"
391 <?php
echo (isset($checksum) && $checksum == 1)
392 ?
' checked="checked"'
397 <tr
><td
><label
for="new_delay_key_write">DELAY_KEY_WRITE
</label
></td
>
398 <td
><input type
="checkbox" name
="new_delay_key_write" id
="new_delay_key_write"
400 <?php
echo (isset($delay_key_write) && $delay_key_write == 1)
401 ?
' checked="checked"'
411 <tr
><td
><label
for="new_transactional">TRANSACTIONAL
</label
></td
>
412 <td
><input type
="checkbox" name
="new_transactional" id
="new_transactional"
414 <?php
echo (isset($transactional) && $transactional == 1)
415 ?
' checked="checked"'
420 <tr
><td
><label
for="new_page_checksum">PAGE_CHECKSUM
</label
></td
>
421 <td
><input type
="checkbox" name
="new_page_checksum" id
="new_page_checksum"
423 <?php
echo (isset($page_checksum) && $page_checksum == 1)
424 ?
' checked="checked"'
432 if (isset($auto_increment) && strlen($auto_increment) > 0
433 && ($is_myisam_or_maria ||
$is_innodb ||
$is_pbxt)) {
435 <tr
><td
><label
for="auto_increment_opt">AUTO_INCREMENT
</label
></td
>
436 <td
><input type
="text" name
="new_auto_increment" id
="auto_increment_opt"
437 value
="<?php echo $auto_increment; ?>" /></td
>
440 } // end if (MYISAM|INNODB)
442 // the outer array is for engines, the inner array contains the dropdown
443 // option values as keys then the dropdown option labels
445 $possible_row_formats = array(
448 'DYNAMIC' => 'DYNAMIC',
453 'DYNAMIC' => 'DYNAMIC'
457 'DYNAMIC' => 'DYNAMIC'
460 'COMPACT' => 'COMPACT',
461 'REDUNDANT' => 'REDUNDANT')
464 $innodb_engine_plugin = PMA_StorageEngine
::getEngine('innodb');
465 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
466 if (!empty($innodb_plugin_version)) {
467 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
469 $innodb_file_format = '';
471 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
472 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
473 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
475 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
477 // for MYISAM there is also COMPRESSED but it can be set only by the
478 // myisampack utility, so don't offer here the choice because if we
479 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
480 // does not return a warning
481 // (if the table was compressed, it can be seen on the Structure page)
483 if (isset($possible_row_formats[$tbl_type])) {
484 $current_row_format = strtoupper($showtable['Row_format']);
485 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
487 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
488 unset($possible_row_formats, $current_row_format);
495 <fieldset
class="tblFooters">
496 <input type
="submit" name
="submitoptions" value
="<?php echo __('Go'); ?>" />
502 <div id
="div_table_copy">
503 <form method
="post" action
="tbl_move_copy.php"
504 onsubmit
="return emptyFormElements(this, 'new_name')">
505 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
506 <input type
="hidden" name
="reload" value
="1" />
508 <legend
><?php
echo __('Copy table to (database<b>.</b>table):'); ?
></legend
>
509 <?php
if (count($GLOBALS['pma']->databases
) > $GLOBALS['cfg']['MaxDbList']) {
511 <input type
="text" maxlength
="100" size
="30" name
="target_db" value
="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
515 <select name
="target_db">
516 <?php
echo $GLOBALS['pma']->databases
->getHtmlOptions(true, false); ?
>
521  
;<strong
>.</strong
> 
;
522 <input type
="text" size
="20" name
="new_name" onfocus
="this.select()" value
="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br
/>
525 'structure' => __('Structure only'),
526 'data' => __('Structure and data'),
527 'dataonly' => __('Data only'));
528 PMA_display_html_radio('what', $choices, 'data', true);
532 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
533 <label
for="checkbox_drop"><?php
echo sprintf(__('Add %s'), 'DROP TABLE'); ?
></label
><br
/>
534 <input type
="checkbox" name
="sql_auto_increment" value
="1" id
="checkbox_auto_increment_cp" />
535 <label
for="checkbox_auto_increment_cp"><?php
echo __('Add AUTO_INCREMENT value'); ?
></label
><br
/>
537 // display "Add constraints" choice only if there are
539 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
541 <input type
="checkbox" name
="add_constraints" value
="1" id
="checkbox_constraints" />
542 <label
for="checkbox_constraints"><?php
echo __('Add constraints'); ?
></label
><br
/>
545 if (isset($_COOKIE['pma_switch_to_new'])
546 && $_COOKIE['pma_switch_to_new'] == 'true') {
547 $pma_switch_to_new = 'true';
550 <input type
="checkbox" name
="switch_to_new" value
="true"
551 id
="checkbox_switch"<?php
echo
552 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
553 ?
' checked="checked"'
555 <label
for="checkbox_switch"><?php
echo __('Switch to copied table'); ?
></label
>
557 <fieldset
class="tblFooters">
558 <input type
="submit" name
="submit_copy" value
="<?php echo __('Go'); ?>" />
563 <br
class="clearfloat"/>
565 <div id
="div_table_maintenance">
567 <legend
><?php
echo __('Table maintenance'); ?
></legend
>
571 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
572 if ($is_myisam_or_maria ||
$is_innodb ||
$is_berkeleydb) {
573 if ($is_myisam_or_maria ||
$is_innodb) {
574 $this_url_params = array_merge($url_params,
575 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
577 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
578 <?php
echo __('Check table'); ?
></a
>
579 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?
>
584 $this_url_params = array_merge($url_params,
585 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
587 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
588 <?php
echo __('Defragment table'); ?
></a
>
589 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?
>
593 if ($is_myisam_or_maria ||
$is_berkeleydb) {
594 $this_url_params = array_merge($url_params,
595 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
597 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
598 <?php
echo __('Analyze table'); ?
></a
>
599 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?
>
603 if ($is_myisam_or_maria) {
604 $this_url_params = array_merge($url_params,
605 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
607 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
608 <?php
echo __('Repair table'); ?
></a
>
609 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?
>
613 if ($is_myisam_or_maria ||
$is_innodb ||
$is_berkeleydb) {
614 $this_url_params = array_merge($url_params,
615 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
617 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
618 <?php
echo __('Optimize table'); ?
></a
>
619 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?
>
623 } // end MYISAM or BERKELEYDB case
624 $this_url_params = array_merge($url_params,
626 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
627 'zero_rows' => sprintf(__('Table %s has been flushed'),
628 htmlspecialchars($GLOBALS['table'])),
632 <li
><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
633 <?php
echo __('Flush the table (FLUSH)'); ?
></a
>
634 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?
>
639 <?php
if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?
>
640 <div id
="div_table_removal">
641 <fieldset
class="caution">
642 <legend
><?php
echo __('Delete data or table'); ?
></legend
>
646 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
647 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
648 $this_url_params = array_merge($url_params,
650 'sql_query' => $this_sql_query,
651 'goto' => 'tbl_structure.php',
653 'zero_rows' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
656 <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); ?>')">
657 <?php
echo __('Empty the table (TRUNCATE)'); ?
></a
>
658 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?
>
662 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
663 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
664 $this_url_params = array_merge($url_params,
666 'sql_query' => $this_sql_query,
667 'goto' => 'db_operations.php',
670 'zero_rows' => sprintf(($tbl_is_view ?
__('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
671 // table name is needed to avoid running
672 // PMA_relationsCleanupDatabase() on the whole db later
673 'table' => $GLOBALS['table'],
676 <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); ?>')">
677 <?php
echo __('Delete the table (DROP)'); ?
></a
>
678 <?php
echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?
>
689 <?php
if (PMA_Partition
::havePartitioning()) {
690 $partition_names = PMA_Partition
::getPartitionNames($db, $table);
691 // show the Partition maintenance section only if we detect a partition
692 if (! is_null($partition_names[0])) {
694 <div id
="div_partition_maintenance">
695 <form method
="post" action
="tbl_operations.php">
696 <?php
echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?
>
698 <legend
><?php
echo __('Partition maintenance'); ?
></legend
>
700 $html_select = '<select name="partition_name">' . "\n";
701 foreach($partition_names as $one_partition) {
702 $one_partition = htmlspecialchars($one_partition);
703 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
705 $html_select .= '</select>' . "\n";
706 printf(__('Partition %s'), $html_select);
707 unset($partition_names, $one_partition, $html_select);
709 'ANALYZE' => __('Analyze'),
710 'CHECK' => __('Check'),
711 'OPTIMIZE' => __('Optimize'),
712 'REBUILD' => __('Rebuild'),
713 'REPAIR' => __('Repair'));
714 PMA_display_html_radio('partition_operation', $choices, '', false);
716 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
717 // I'm not sure of the best way to display that; this link does
718 // not depend on the Go button
719 $this_url_params = array_merge($url_params,
721 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
724 <br
/><a href
="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
725 <?php
echo __('Remove partitioning'); ?
></a
>
727 <fieldset
class="tblFooters">
728 <input type
="submit" name
="submit_partition" value
="<?php echo __('Go'); ?>" />
736 // Referential integrity check
737 // The Referential integrity check was intended for the non-InnoDB
738 // tables for which the relations are defined in pmadb
739 // so I assume that if the current table is InnoDB, I don't display
740 // this choice (InnoDB maintains integrity by itself)
742 if ($cfgRelation['relwork'] && ! $is_innodb) {
743 PMA_DBI_select_db($GLOBALS['db']);
744 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
748 <!-- Referential integrity check
-->
749 <div id
="div_referential_integrity">
751 <legend
><?php
echo __('Check referential integrity:'); ?
></legend
>
755 foreach ($foreign AS $master => $arr) {
756 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
757 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
758 . PMA_backquote($arr['foreign_table']);
759 if ($arr['foreign_table'] == $GLOBALS['table']) {
760 $foreign_table = $GLOBALS['table'] . '1';
761 $join_query .= ' AS ' . PMA_backquote($foreign_table);
763 $foreign_table = $arr['foreign_table'];
765 $join_query .= ' ON '
766 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
767 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
769 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
771 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
773 $this_url_params = array_merge($url_params,
774 array('sql_query' => $join_query));
777 . PMA_generate_common_url($this_url_params)
778 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
779 . '</a></li>' . "\n";
780 } // foreach $foreign
781 unset($foreign_table, $join_query);
787 } // end if ($foreign)
789 } // end if (!empty($cfg['Server']['relation']))
793 * Displays the footer
795 require './libraries/footer.inc.php';
798 function PMA_set_global_variables_for_engine($tbl_type)
800 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
802 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
803 $upper_tbl_type = strtoupper($tbl_type);
805 //Options that apply to MYISAM usually apply to MARIA
806 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' ||
$upper_tbl_type == 'MARIA');
807 $is_maria = ($upper_tbl_type == 'MARIA');
809 $is_isam = ($upper_tbl_type == 'ISAM');
810 $is_innodb = ($upper_tbl_type == 'INNODB');
811 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
812 $is_pbxt = ($upper_tbl_type == 'PBXT');