sql >> データベース >  >> RDS >> Mysql

INT(3)列が値を適切な長さにクリップせず、完全な値を挿入できるようにする-MySQL

    FROM 何をしますかMySQLのint(size)のsize "はどういう意味ですか?

    mysql> create table a ( a tinyint );
    Query OK, 0 rows affected (0.29 sec)
    mysql> show columns from a;
    +-------+------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +-------+------------+------+-----+---------+-------+
    | a | tinyint(4) | YES | | NULL | |
    +-------+------------+------+-----+---------+-------+
    1 row in set (0.26 sec)
    
    mysql> alter table a change a a tinyint(1);
    Query OK, 0 rows affected (0.09 sec)
    Records: 0 Duplicates: 0 Warnings: 0
    
    mysql> insert into a values (100);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from a;
    +-----+
    | a |
    +-----+
    | 100 |
    +-----+
    1 row in set (0.00 sec)
    
    
    2 Some code to better explain what I described so clumsily.
    mysql> create table b ( b int (4));
    Query OK, 0 rows affected (0.25 sec)
    
    mysql> insert into b values (10000);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from b;
    +-------+
    | b |
    +-------+
    | 10000 |
    +-------+
    1 row in set (0.00 sec)
    
    mysql> alter table b change b b int(11);
    Query OK, 1 row affected (0.00 sec)
    Records: 1 Duplicates: 0 Warnings: 0
    
    mysql> select * from b;
    +-------+
    | b |
    +-------+
    | 10000 |
    +-------+
    1 row in set (0.00 sec)
    
    mysql> alter table b change b b int(11) zerofill;
    Query OK, 1 row affected (0.00 sec)
    Records: 1 Duplicates: 0 Warnings: 0
    
    mysql> select * from b;
    +-------------+
    | b |
    +-------------+
    | 00000010000 |
    +-------------+
    1 row in set (0.00 sec)
    
    mysql> alter table b change b b int(4) zerofill;
    Query OK, 1 row affected (0.08 sec)
    Records: 1 Duplicates: 0 Warnings: 0
    
    mysql> select * from b;
    +-------+
    | b |
    +-------+
    | 10000 |
    +-------+
    1 row in set (0.00 sec)
    
    mysql> alter table b change b b int(6) zerofill;
    Query OK, 1 row affected (0.01 sec)
    Records: 1 Duplicates: 0 Warnings: 0
    
    mysql> select * from b;
    +--------+
    | b |
    +--------+
    | 010000 |
    +--------+
    1 row in set (0.00 sec)
    


    1. OSErrorに対処するにはどうすればよいですか:ElasticBeanstalkのデプロイ中にmysql_confignot foundエラーが発生しますか?

    2. 同じ値を持つテーブル内の他の行の数

    3. SQLの各行の2列からAVERAGEを計算します

    4. エンコーディングの修正