用SQL语句创建Access表

很久以前弄的,用了一天的时间,没有什么技巧,却很实用.很乱,复制下来到记事本,把自动换行去掉再看,就有条理了:) ---------------------------------------------------------------------------- 类型名称 TYPE 备注 ---------------------------------------------------------------------------- 自动编号 integer + identity(1,1) 文本 varchar(50) 括号中

很久以前弄的,用了一天的时间,没有什么技巧,却很实用.很乱,复制下来到记事本,把自动换行去掉再看,就有条理了:)
----------------------------------------------------------------------------
         类型名称         TYPE               备注
----------------------------------------------------------------------------
   自动编号         integer           + identity(1,1)
   文本             varchar(50)       括号中的数字为文本长度
   长整型           integer 
         整型             short  
   双精度型         double,float
         单精度型         real
   字节型           byte 
   小数             NUMERIC(6,2)
   货币             money
   备注             text
         日期/时间        date,time,datetime
   是/否            bit
   OLE 对象         OLEObject

----------------------------------------------------------------------------

         主键             primary key 
         必填             not null
         默认值           default            当为日期型时为   default date()
-----------------------------------------------------------------------------

示例
                  表名     字段名             类型                             附属属性                  说明
                  -------  ---------        ------------        ---------------------------------   -------------------
     create table mytable (m_id             integer             identity(1,1)     primary key    ,--自增型,主键  
                           m_class          varchar(50)         not null          default 'AAA'  ,--文本,非空,默认值'AAA'  
                           m_int            integer             not null                         ,--长整型,非空
                           m_numeric        NUMERIC(6,2)                                         ,--小数型
                           m_money          money               not null          default 0.00   ,--货币型,非空,默认值0.00 
                           m_memo           text                                                 ,--备注型
                           m_date           date                                  default date() ,--日期型,默认为当前日期
                           m_boolean        bit                                   default yes    ,--布尔型,默认为yes
                           m_blob           OLEObject                                            ,--BLOB型
                           m_double         double                                               ,--双精度型
                           m_float          real)                                                 --单精度型
----------------------------------------------------------------------------------------------------------------------------

创建索引
      
    示例1
             create index myindex on mytable (m_class [DESC, ASC], m_int)
    示例2
       create unique index myindex on mytable (m_class)  --创建无重复索引
    注意:主键字段会被自动建立为没有重复的索引 

posted on 2011-04-15 17:48  xxmcu  阅读(846)  评论(0编辑  收藏  举报

导航