Access数据表字段类型大全

365bet在线客服 📅 2025-08-13 02:28:57 👤 admin 👁️ 5288 ❤️ 612
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) --创建无重复索引

注意:主键字段会被自动建立为没有重复的索引

上面是我摘抄的,下面的是能够正确执行建表的语句:

CREATE TABLE [NT_channel_product3](

[Id] counter CONSTRAINT id PRIMARY KEY,

[ChID] long NOT NULL ,title text(100) NOT NULL ,

[ClassID] long NOT NULL ,[SpecialID] text (200) NULL ,

[TitleColor] text (10) NULL ,

[TitleITF] byte NULL ,

[TitleBTF] byte NULL ,

[PicURL] text (200) NULL ,

[Content] memo NULL ,

[NaviContent] text (200) NULL ,

[ContentProperty] text (9) NULL ,

[Author] text (100) NULL ,

[Editor] text (50) NULL ,

[Souce] text (100) NULL ,

[OrderID] byte NOT NULL ,

[Tags] text (100) NULL ,

[Templet] text (200) NULL ,

[SavePath] text (200) NULL ,

[FileName] text (100) NULL ,

[isDelPoint] byte NOT NULL ,

[Gpoint] long NULL ,

[iPoint] long NULL ,

[GroupNumber] memo NULL ,

[Metakeywords] text (200) NULL ,

[Metadesc] text (200) NULL ,

[Click] long NULL ,

[CreatTime] datetime NULL ,

[isHTML] byte NOT NULL ,

[isConstr] byte NOT NULL ,

[ConstrTF] byte NOT NULL

)

相关推荐

教你“玩转”广州国庆主题城市AR秀
365bet在线客服

教你“玩转”广州国庆主题城市AR秀

📅 07-11 👁️ 6125
忱的组词、含义
365bet备用器

忱的组词、含义

📅 07-11 👁️ 1662
苹果输入法换行怎么换
365bet备用器

苹果输入法换行怎么换

📅 08-07 👁️ 9140