Here's my output... 5.0.21 running under XP.
Notice the column some_text.. Again, apologies for the lack of
formatting.
mysqlselect version() ;
+---------------------+
| version() |
+---------------------+
| 5.0.21-community-nt |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysqlshow columns from my_table ;
+---------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| some_text | varchar(20) | NO | | NULL | |
| other_text | varchar(20) | YES | | aaa | |
| another_table | varchar(20) | YES | | NULL | |
+---------------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysqlshow create table my_table ;
+----------+----------------------------------
----------------------------------------------
---------------------------------------------+
| Table | Create Table
|
+----------+----------------------------------
----------------------------------------------
---------------------------------------------+
| my_table | CREATE TABLE "my_table" (
"id" int(11) NOT NULL auto_increment,
"some_text" varchar(20) NOT NULL,
"other_text" varchar(20) default 'aaa',
"another_table" varchar(20) default NULL,
PRIMARY KEY ("id")
) |
+----------+----------------------------------
----------------------------------------------
---------------------------------------------+
Bill Karwin wrote:
ax******@gmail.com wrote:
create table some_table
(id int not null auto_increment,
some_text varchar(20) not null,
other_text varchar(20) default 'aaa',
another_text varchar(20),
primary key (id)
) type=innodb;
I execute "show columns from some_table" using both ODBC, connector/J
and mysql command line.
The command line returns "some_text" as having a NULL default.
I just tried your example table on my instance of MySQL 5.0.21, and it
shows this:
mysqlshow columns from some_table;
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| some_text | varchar(20) | NO | | | |
| other_text | varchar(20) | YES | | aaa | |
| another_text | varchar(20) | YES | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
Apologies if the formatting gets messed up by proportional fonts.
Anyway, notice that the "some_text" column shows NO for its nullability,
and an empty space for its default value.
So it is consistent with what you saw in ODBC and Java, and also agrees
with the docs on the issue. Perhaps you misread the output of show
columns in the mysql monitor?
Regards,
Bill K.