List:General Discussion« Previous MessageNext Message »
From:Jay J Date:January 24 2000 11:14am
Subject:Re: What is wrong using tinyint
View as plain text  
----- Original Message ----- 
From: "Amit Bhargava" <bhargava@stripped>
To: "MySQL Forum" <mysql@stripped>
Sent: Monday, January 24, 2000 4:56 AM
Subject: What is wrong using tinyint


> Hi,
> 
> Please tell me as to what goes wrong when I:
> 
> create table test
> (
> n tinyint(4),
> m varchar(10)
> )
> 
> insert into test values (0103,'MYName')
> - Quesry OK
> 
> select * from test 
> ----------------------------
> |     n   |     m         |
> ----------------------------
> |   127 |  MYName  |
> ----------------------------
> 
> when I alter the table and make the coulmn 'n' of datatype "int(4)"
> 
> and run
> 
> select * from test 
> ----------------------------
> |     n     |     m         |
> ----------------------------
> |  0103  |  MYName  |
> ----------------------------
> 
> What am I missing
> 
> Amit Bhargava

How 'bout this:

mysql> create table test
    -> (
    -> n tinyint(4) ZEROFILL,
    -> m varchar(10)
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> insert into test values (0103,'MYName');
Query OK, 1 row affected (0.02 sec)

mysql> select * from test;
+------+--------+
| n    | m      |
+------+--------+
| 0103 | MYName |
+------+--------+
1 row in set (0.01 sec)

mysql> explain test;
+-------+------------------------------+------+-----+---------+-------+
| Field | Type                         | Null | Key | Default | Extra |
+-------+------------------------------+------+-----+---------+-------+
| n     | tinyint(4) unsigned zerofill | YES  |     | NULL    |       |
| m     | varchar(10)                  | YES  |     | NULL    |       |
+-------+------------------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

-Jay J


Thread
What is wrong using tinyintAmit Bhargava24 Jan
  • Re: What is wrong using tinyintViktor Fougstedt24 Jan
    • Re: What is wrong using tinyintMatthias Urlichs24 Jan
      • RE: What is wrong using tinyintNicolas Prade24 Jan
        • Re: What is wrong using tinyintFaisal Nasim24 Jan
  • Re: What is wrong using tinyintMatthias Urlichs24 Jan
  • Re: What is wrong using tinyintJay J24 Jan