SQL variable type

  1.数值型

     Integer: 

     Float:

  2.char

    char(m):    固定长度字符串,固定几个就是几个,不会多,也不会少,最多255个字节

    varchar(m):可变长度字符串,永远是内容加一个字节

  3.string    

    text:words

    blob:binary data like (pic ,rar file);

    ENUM:   all memers is :65525;每次只能用插入一个的值,像星期这种的数据

        

    SET:all members is 64;集合可以插入多个

  4.data and time

    Data   yyyy-mm-dd

    Time   hh:mm:ss

    TimeStamp  

  但是没有什么用,可以用一个整数代替这样如果是处理数据更加的合理。

  5.字段的属性

  unsigned 

  create table table_name(id int unsigned);

      zerofill 

  create table table_name(id int(5) zerofill)//不满5位前面自动补零

    auto_increment

  create table table_name(id int auto_increment )

    insert table_name(id) values(null);or insert table_name(id) values(0);

  6.not null

    在SQL中找到不大用空的字段,因为我们在做Php中,如果从SQL中读取数据,我们就不能确定,空到底是什么值,所以出现了一个not null的属性

    create table table_name(id int not null);

    7.default

    create table table_name(id int not null default);

 

 

So give a good example: 

create table table_name(

  id int unsigned not null auto_increment primary key,

  name varchar(30) not null default  ' ' unique,//unique 代表名字不可以重复

  height double(3,1) not null default 0.00,

)

 

     

  

 

  

posted @ 2012-07-31 15:26  Epirus  阅读(414)  评论(0编辑  收藏  举报