2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays table structure infos like fields/columns, indexes, size, rows
5 * and allows manipulation of indexes and columns/fields
13 require_once './libraries/common.inc.php';
14 require_once './libraries/mysql_charsets.lib.php';
15 require_once './libraries/relation.lib.php';
17 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
20 * handle multiple field commands if required
22 * submit_mult_*_x comes from IE if <input type="img" ...> is used
24 if (isset($_REQUEST['submit_mult_change_x'])) {
25 $submit_mult = __('Change');
26 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
27 $submit_mult = __('Drop');
28 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
29 $submit_mult = __('Primary');
30 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
31 $submit_mult = __('Index');
32 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
33 $submit_mult = __('Unique');
34 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
35 $submit_mult = __('Fulltext');
36 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
37 $submit_mult = __('Browse');
38 } elseif (isset($_REQUEST['submit_mult'])) {
39 $submit_mult = $_REQUEST['submit_mult'];
40 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
41 $submit_mult = 'row_delete';
42 if (isset($_REQUEST['selected'])) {
43 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
47 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
48 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
49 if ($submit_mult == __('Browse')) {
50 // browsing the table displaying only selected fields/columns
51 $GLOBALS['active_page'] = 'sql.php';
53 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
54 if ($sql_query == '') {
55 $sql_query .= 'SELECT ' . PMA_backquote($sval);
57 $sql_query .= ', ' . PMA_backquote($sval);
61 // what is this htmlspecialchars() for??
62 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
63 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
67 // handle multiple field commands
68 // handle confirmation of deleting multiple fields/columns
69 $action = 'tbl_structure.php';
70 require './libraries/mult_submits.inc.php';
71 //require_once './libraries/header.inc.php';
72 //require_once './libraries/tbl_links.inc.php';
74 if (empty($message)) {
75 $message = PMA_Message
::success();
81 * Gets the relation settings
83 $cfgRelation = PMA_getRelationsParam();
88 require_once './libraries/tbl_common.php';
89 $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php';
90 $url_params['goto'] = 'tbl_structure.php';
91 $url_params['back'] = 'tbl_structure.php';
94 * Prepares the table structure display
99 * Gets tables informations
101 require_once './libraries/tbl_info.inc.php';
104 * Displays top menu links
106 require_once './libraries/tbl_links.inc.php';
107 require_once './libraries/Index.class.php';
109 // 2. Gets table keys and retains them
110 // @todo should be: $server->db($db)->table($table)->primary()
111 $primary = PMA_Index
::getPrimary($table, $db);
113 $columns_with_unique_index = array();
114 foreach (PMA_Index
::getFromTable($table, $db) as $index) {
115 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
116 $columns = $index->getColumns();
117 foreach ($columns as $column_name => $dummy) {
118 $columns_with_unique_index[$column_name] = 1;
122 unset($index, $columns, $column_name, $dummy);
125 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
126 $fields_cnt = PMA_DBI_num_rows($fields_rs);
129 // Get more complete field information
130 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
131 // but later, if the analyser returns more information, it
132 // could be executed for any MySQL version and replace
133 // the info given by SHOW FULL FIELDS FROM.
135 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
136 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
137 // and SHOW CREATE TABLE says NOT NULL (tested
138 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
140 $show_create_table = PMA_DBI_fetch_value(
141 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
143 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
146 * prepare table infos
148 // action titles (image or string)
150 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
151 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
152 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
153 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
154 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
155 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
156 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
157 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
158 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
159 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
160 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
161 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
164 * Displays the table structure ('show table' works correct since 3.23.03)
166 /* TABLE INFORMATION */
170 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm">
171 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
172 <table id
="tablestructure" class="data">
175 <th id
="th<?php echo ++$i; ?>"></th
>
176 <th id
="th<?php echo ++$i; ?>">#</th>
177 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Column'); ?
></th
>
178 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Type'); ?
></th
>
179 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Collation'); ?
></th
>
180 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Attributes'); ?
></th
>
181 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Null'); ?
></th
>
182 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Default'); ?
></th
>
183 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Extra'); ?
></th
>
184 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
185 <th id
="th<?php echo ++$i; ?>"><?php
echo __('View'); ?
></th
>
187 <th colspan
="7" id
="th<?php echo ++$i; ?>"><?php
echo __('Action'); ?
></th
>
199 $comments_map = array();
202 if ($GLOBALS['cfg']['ShowPropertyComments']) {
203 require_once './libraries/relation.lib.php';
204 require_once './libraries/transformations.lib.php';
206 //$cfgRelation = PMA_getRelationsParam();
208 $comments_map = PMA_getComments($db, $table);
210 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
211 $mime_map = PMA_getMIME($db, $table, true);
216 $aryFields = array();
217 $checked = (!empty($checkall) ?
' checked="checked"' : '');
220 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
223 $aryFields[] = $row['Field'];
225 $type = $row['Type'];
226 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
228 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
229 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
231 // for the case ENUM('–','“')
232 $type = htmlspecialchars($type);
240 $type_nowrap = ' nowrap="nowrap"';
241 // strip the "BINARY" attribute, except if we find "BINARY(" because
242 // this would be a BINARY or VARBINARY field type
243 if (!preg_match('@BINARY[\(]@i', $type)) {
244 $type = preg_replace('@BINARY@i', '', $type);
246 $type = preg_replace('@ZEROFILL@i', '', $type);
247 $type = preg_replace('@UNSIGNED@i', '', $type);
252 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
253 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
258 $unsigned = stristr($row['Type'], 'unsigned');
259 $zerofill = stristr($row['Type'], 'zerofill');
262 unset($field_charset);
263 if ((substr($type, 0, 4) == 'char'
264 ||
substr($type, 0, 7) == 'varchar'
265 ||
substr($type, 0, 4) == 'text'
266 ||
substr($type, 0, 8) == 'tinytext'
267 ||
substr($type, 0, 10) == 'mediumtext'
268 ||
substr($type, 0, 8) == 'longtext'
269 ||
substr($type, 0, 3) == 'set'
270 ||
substr($type, 0, 4) == 'enum'
272 if (strpos($type, ' character set ')) {
273 $type = substr($type, 0, strpos($type, ' character set '));
275 if (!empty($row['Collation'])) {
276 $field_charset = $row['Collation'];
284 // Display basic mimetype [MIME]
285 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
286 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
293 $attribute = 'BINARY';
296 $attribute = 'UNSIGNED';
299 $attribute = 'UNSIGNED ZEROFILL';
302 // MySQL 4.1.2+ TIMESTAMP options
303 // (if on_update_current_timestamp is set, then it's TRUE)
304 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
305 $attribute = 'on update CURRENT_TIMESTAMP';
308 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
309 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
311 if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
316 if (!isset($row['Default'])) {
317 if ($row['Null'] == 'YES') {
318 $row['Default'] = '<i>NULL</i>';
321 $row['Default'] = htmlspecialchars($row['Default']);
324 $field_encoded = urlencode($row['Field']);
325 $field_name = htmlspecialchars($row['Field']);
326 $displayed_field_name = $field_name;
328 // underline commented fields and display a hover-title (CSS only)
330 if (isset($comments_map[$row['Field']])) {
331 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
334 if ($primary && $primary->hasColumn($field_name)) {
335 $displayed_field_name = '<u>' . $field_name . '</u>';
339 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
341 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
344 <?php
echo $rownum; ?
>
346 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
347 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
348 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
349 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
350 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
351 <td nowrap
="nowrap"><?php
352 if (isset($row['Default'])) {
353 if ($extracted_fieldspec['type'] == 'bit') {
354 // here, $row['Default'] contains something like b'010'
355 echo PMA_convert_bit_default_value($row['Default']);
357 echo $row['Default'];
361 echo '<i>' . _pgettext('None for default','None') . '</i>';
363 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
365 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
366 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
368 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
370 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
371 <?php
echo $titles['Change']; ?
></a
>
374 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>"
375 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
376 <?php
echo $titles['Drop']; ?
></a
>
380 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
381 echo $titles['NoPrimary'] . "\n";
385 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>"
386 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
387 <?php
echo $titles['Primary']; ?
></a
>
395 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
isset($columns_with_unique_index[$field_name])) {
396 echo $titles['NoUnique'] . "\n";
400 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
401 <?php
echo $titles['Unique']; ?
></a
>
409 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type) {
410 echo $titles['NoIndex'] . "\n";
414 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
415 <?php
echo $titles['Index']; ?
></a
>
422 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')
423 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
424 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'char'))) {
427 <td align
="center" nowrap
="nowrap">
428 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
429 <?php
echo $titles['IdxFulltext']; ?
></a
>
435 <td align
="center" nowrap
="nowrap">
436 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
439 } // end if... else...
441 } // end if (! $tbl_is_view && ! $db_is_information_schema)
445 unset($field_charset);
448 echo '</tbody>' . "\n"
451 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
454 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
455 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
456 <a href
="<?php echo $checkall_url; ?>&checkall=1"
457 onclick
="if (markAllRows('fieldsForm')) return false;">
458 <?php
echo __('Check All'); ?
></a
>
460 <a href
="<?php echo $checkall_url; ?>"
461 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
462 <?php
echo __('Uncheck All'); ?
></a
>
464 <i
><?php
echo __('With selected:'); ?
></i
>
467 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
469 if (! $tbl_is_view && ! $db_is_information_schema) {
470 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
471 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
472 if ('ARCHIVE' != $tbl_type) {
473 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
474 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
475 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
477 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')) {
478 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
490 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
491 if ($cfg['PropertiesIconic']) {
492 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
494 echo __('Print view');
498 if (! $tbl_is_view && ! $db_is_information_schema) {
500 // if internal relations are available, or foreign keys are supported
501 // ($tbl_type comes from libraries/tbl_info.inc.php)
502 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
504 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
505 if ($cfg['PropertiesIconic']) {
506 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
508 echo __('Relation view');
513 <a href
="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
514 if ($cfg['PropertiesIconic']) {
515 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
517 echo __('Propose table structure');
519 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
522 if(PMA_Tracker
::isActive())
524 echo '<a href="tbl_tracking.php?' . $url_query . '">';
526 if ($cfg['PropertiesIconic'])
528 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
530 echo __('Track table') . '</a>';
535 <form method
="post" action
="tbl_addfield.php"
536 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
538 echo PMA_generate_common_hidden_inputs($db, $table);
539 if ($cfg['PropertiesIconic']) {
540 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
542 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
544 // I tried displaying the drop-down inside the label but with Firefox
545 // the drop-down was blinking
546 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
547 foreach ($aryFields as $fieldname) {
548 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
551 $fieldOptions .= '</select>';
554 'last' => __('At End of Table'),
555 'first' => __('At Beginning of Table'),
556 'after' => sprintf(__('After %s'), '')
558 PMA_display_html_radio('field_where', $choices, 'last', false);
560 unset($fieldOptions, $choices);
562 <input type
="submit" value
="<?php echo __('Go'); ?>" />
569 * If there are more than 20 rows, displays browse/select/insert/empty/drop
572 if ($fields_cnt > 20) {
573 require './libraries/tbl_links.inc.php';
574 } // end if ($fields_cnt > 20)
580 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
584 echo PMA_Index
::getView($table, $db);
587 <form action
="./tbl_indexes.php" method
="post"
588 onsubmit
="return checkFormElementInRange(this, 'idx_num_fields',
589 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
593 echo PMA_generate_common_hidden_inputs($db, $table);
594 echo sprintf(__('Create an index on %s columns'),
595 '<input type="text" size="2" name="added_fields" value="1" />');
597 <input type
="submit" name
="create_index" value
="<?php echo __('Go'); ?>"
598 onclick
="return checkFormElementInRange(this.form,
600 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
608 PMA_generate_slider_effect('tablestatistics', __('Details...'));
611 * Displays Space usage and row statistics
613 // BEGIN - Calc Table Space
614 // Get valid statistics whatever is the table type
615 if ($cfg['ShowStats']) {
616 if (empty($showtable)) {
617 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
621 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
622 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
628 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
630 // this is to display for example 261.2 MiB instead of 268k KiB
633 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
634 if ($mergetable == false) {
635 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
637 // InnoDB returns a huge value in Data_free, do not use it
638 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
639 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
640 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
642 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
644 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
645 if ($table_info_num_rows > 0) {
646 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
653 <a name
="showusage"></a
>
654 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
655 <table id
="tablespaceusage" class="data">
656 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
659 <th
><?php
echo __('Type'); ?
></th
>
660 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
664 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
665 <th
class="name"><?php
echo __('Data'); ?
></th
>
666 <td
class="value"><?php
echo $data_size; ?
></td
>
667 <td
class="unit"><?php
echo $data_unit; ?
></td
>
670 if (isset($index_size)) {
672 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
673 <th
class="name"><?php
echo __('Index'); ?
></th
>
674 <td
class="value"><?php
echo $index_size; ?
></td
>
675 <td
class="unit"><?php
echo $index_unit; ?
></td
>
679 if (isset($free_size)) {
681 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
682 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
683 <td
class="value"><?php
echo $free_size; ?
></td
>
684 <td
class="unit"><?php
echo $free_unit; ?
></td
>
686 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
687 <th
class="name"><?php
echo __('Effective'); ?
></th
>
688 <td
class="value"><?php
echo $effect_size; ?
></td
>
689 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
693 if (isset($tot_size) && $mergetable == false) {
695 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
696 <th
class="name"><?php
echo __('Total'); ?
></th
>
697 <td
class="value"><?php
echo $tot_size; ?
></td
>
698 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
702 // Optimize link if overhead
703 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
705 <tr
class="tblFooters">
706 <td colspan
="3" align
="center">
707 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
708 if ($cfg['PropertiesIconic']) {
709 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
711 echo __('Optimize table');
724 <table id
="tablerowstats" class="data">
725 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
728 <th
><?php
echo __('Statements'); ?
></th
>
729 <th
><?php
echo __('Value'); ?
></th
>
734 if (isset($showtable['Row_format'])) {
736 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
737 <th
class="name"><?php
echo __('Format'); ?
></th
>
738 <td
class="value"><?php
739 if ($showtable['Row_format'] == 'Fixed') {
741 } elseif ($showtable['Row_format'] == 'Dynamic') {
744 echo $showtable['Row_format'];
750 if (! empty($showtable['Create_options'])) {
752 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
753 <th
class="name"><?php
echo __('Options'); ?
></th
>
754 <td
class="value"><?php
755 if ($showtable['Create_options'] == 'partitioned') {
756 echo __('partitioned');
758 echo $showtable['Create_options'];
764 if (!empty($tbl_collation)) {
766 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
767 <th
class="name"><?php
echo __('Collation'); ?
></th
>
768 <td
class="value"><?php
769 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
774 if (!$is_innodb && isset($showtable['Rows'])) {
776 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
777 <th
class="name"><?php
echo __('Rows'); ?
></th
>
778 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
782 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
784 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
785 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
786 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
790 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
792 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
793 <th
class="name"><?php
echo __(' Row size '); ?
> ø
;</th
>
794 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
798 if (isset($showtable['Auto_increment'])) {
800 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
801 <th
class="name"><?php
echo __('Next'); ?
> Autoindex
</th
>
802 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
806 if (isset($showtable['Create_time'])) {
808 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
809 <th
class="name"><?php
echo __('Creation'); ?
></th
>
810 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
814 if (isset($showtable['Update_time'])) {
816 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
817 <th
class="name"><?php
echo __('Last update'); ?
></th
>
818 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
822 if (isset($showtable['Check_time'])) {
824 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
825 <th
class="name"><?php
echo __('Last check'); ?
></th
>
826 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
834 <!-- close slider div
-->
839 // END - Calc Table Space
841 require './libraries/tbl_triggers.lib.php';
843 echo '<div class="clearfloat"></div>' . "\n";
846 * Displays the footer
848 require_once './libraries/footer.inc.php';