如何在phpMyAdmin中将整数设置为默认无符号?

cwd*_*cwd 6 mysql phpmyadmin

如何在phpMyAdmin中将整数设置为默认无符号?大多数时候我将它们设置为自动递增,而我不需要负值.有没有办法可以做到这一点?

Rya*_*ner 6

这可以在更高版本的phpMyAdmin中使用Attributes选项.

  • 添加新列时,第六个选项是"属性".二进制,无符号,无符号zerofill,以及更新当前时间戳.在此处设置Unsigned将为您提供unsigned int列. (2认同)
  • 你误解了这个问题 - 我想看到的行为是,当我选择类型为"Int"时,我希望它默认为"无符号"... (2认同)

cwd*_*cwd 0

将其添加到common.inc.php

$GLOBALS['js_include'][] = 'extension.js';
Run Code Online (Sandbox Code Playgroud)

extension.js在文件夹中创建一个文件,名为js

jQuery(function(){
    $('#create_table_form select[name=tbl_collation]').val('utf8_general_ci');
    $('#append_fields_form select.column_type, #create_table_form select.column_type').live('change keyup',function(k,v){
        var field = $(this).attr('name').replace(/[^0-9]/g,'');
        var val = $(this).val();
        $('[name="field_attribute['+field+']"] option').attr('selected',false);
        $('[name="field_collation['+field+']"] option').attr('selected',false);
        $('[name="field_length['+field+']"]').val('');
        if(val == 'VARCHAR'){
            $('[name="field_length['+field+']"]').val('255');
            $('[name="field_collation['+field+']"]').val('utf8_general_ci');
        }
        if(val == 'INT'){
            $('[name="field_attribute['+field+']"]').val('UNSIGNED');
            $('[name="field_length['+field+']"]').val('11');
        }   
    });
});
Run Code Online (Sandbox Code Playgroud)

使用 phpMyAdmin 3.4.2 进行测试。还设置了一些其他不错的默认值。