-----------------------------------------------------------------
類型名稱 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