zoukankan      html  css  js  c++  java
  • Access数据类型备忘

    今天在用C#创建Access数据库的时候遇到了一个字段类型的问题,因为程序创建数据库表这个在SqlServer上比较常见,在百度中找了很久,把相关的属性抄录下来吧,以供以后使用。

    1、动态创建Access数据库:本人觉得用ADOX的方式简单是简单,但是还是需要一个DLL组建方可以实现数据库的创建,所以那我们就换个思路吧,为什么不可以这样来呢。创建一个空白的数据库,之后通过程序去创建数据库的表,这样的效果不是也可以实现的?

    2、动态创建Access数据库表:Create Table Admin (ID INT,UserName VarChar(50),UserPass 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)  --创建无重复索引
    注意:主键字段会被自动建立为没有重复的索引

        /*
         * INTEGER(整型)、LONG(长整型)、 SINGLE(单精度浮点数)、DOUBLE(双精度浮点数)、DATETIME(日期型,也可以写成DATE)、
         * BIT(布尔型)、 TEXT(字符串型,最大255个字节)、MEMO(字符串型,最大可达1.2G字节)、 COUNTER(自动递增长整型,可确定记录的唯一性)、
         * CURRENCY(货币型,精确到小数点左边15位,右边4位)、 BINARY(字节型,最大255个)、LONGBINARY(用于OLE对象)、GUID(全局唯一标识符)。
         */

    版权说明

      如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
      作      者:温景良
      文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

  • 相关阅读:
    MOSS中的User的Title, LoginName, DisplayName, SID之间的关系
    如何在Network Monitor中高亮间隔时间过长的帧?
    SharePoint服务器如果需要安装杀毒软件, 需要注意什么?
    如何查看SQL Profiler? 如何查看SQL死锁?
    什么是Telnet
    The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.
    Windows SharePoint Service 3.0的某个Web Application无搜索结果
    网络连接不上, 有TCP错误, 如果操作系统是Windows Server 2003, 请尝试一下这里
    在WinDBG中查看内存的命令
    The virtual machine could not be started because the hypervisor is not running
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1401575.html
Copyright © 2011-2022 走看看