-----------------------------------------------------------------
类型名称 TYPE 备注
-----------------------------------------------------------------
文本 Char(n) 其中n表示字段大小
文本 Varchar(n)
文本 Text
数字[字节] Byte
数字[整型] Short
数字[长整型] Long, integer
数字[单精度] Single, Real
数字[双精度] Double, Float
数字[自动编号] Integer Identity(1,1)
数字[自动编号] Counter
二进制 Binary
货币 Currency, Money
备注 Memo
日期/时间 Date, Time, Datetime
是/否 Bit
OLE 对象 OLEObject
-----------------------------------------------------
主键 primary key
必填 not null
默认值 default 当为日期型时为 default date()
-----------------------------------------------------
在使用Create Table 语句时, 尽量使用如下字段定义类型:
Boolean、Integer、Long、Currency、Single、Double、Date、String 和 Variant(默认)
-----------------------------------------------------
示例
表名 字段名 类型 附属属性 说明
------- --------- ------------ --------------------------------- -------------------
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_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) --创建无重复索引
注意:主键字段会被自动建立为没有重复的索引
修改属性
ALTER TABLE Admin ALTER COLUMN UserName VarChar(200)
增加列
ALTER TABLE Admin ADD UserPass VARCHAR(50) NULL
删除列
ALTER TABLE Admin DROP COLUMN UserPass
该内容整理自 http://www.940194.cn/ShowData/2008-10/74.html