Access資料表欄位類型與建表示例

來源:互聯網
上載者:User

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

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

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.