请问 在mysql 中 创建表时
表字段加上注释 怎么查看 在 mysql Command line Client 中查看 如 
create table users (
id int primary key auto_increment  这里怎样写字段注释 ,
userName varchar(20) not null
);

解决方案 »

  1.   


    CREATE TABLE `abc` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `ReporterName` varchar(50) NOT NULL COMMENT '此处写你的注释',
    )
      

  2.   

     `create_time` datetime DEFAULT NULL COMMENT '创建日期',
      

  3.   

    create table users (
    id int primary key auto_increment comment '主键',
    userName varchar(20) not null
    );
      

  4.   

    用 COMMENT '你的内容'即可
      

  5.   


    show create table 'tb' ;
    或者
    desc 'tb';
      

  6.   

    SHOW CREATE TABLE tbl_nameShows the CREATE TABLE statement that creates the given table. This statement also works with views. mysql> SHOW CREATE TABLE t\G
    *************************** 1. row ***************************
           Table: t
    Create Table: CREATE TABLE t (
      id INT(11) default NULL auto_increment,
      s char(60) default NULL,
      PRIMARY KEY (id)
    ) ENGINE=MyISAM
      

  7.   

    mysql> create table tcomment
        -> (id int primary key comment 'this is primary key for demo',
        -> col2 varchar(32));
    Query OK, 0 rows affected (0.17 sec)mysql> show create table tcomment;
    +----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table    | Create Table
                                                                                                     |
    +----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | tcomment | CREATE TABLE `tcomment` (
      `id` int(11) NOT NULL COMMENT 'this is primary key for demo',
      `col2` varchar(32) default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
    +----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)