access數(shù)據(jù)庫用sql語句添加字段,修改字段,刪除字段
來源:易賢網(wǎng) 閱讀:1485 次 日期:2014-10-27 13:59:21
溫馨提示:易賢網(wǎng)小編為您整理了“access數(shù)據(jù)庫用sql語句添加字段,修改字段,刪除字段”,方便廣大網(wǎng)友查閱!

以下就是示例:

用 ddl 的 create table 建立一個表 table1 ,主鍵是自動編號字段,另一個字段是長度是 10 的文本字段。

代碼如下:

create table table1 (id counter constraint primarykey primary key, mytext text (10))

再建一個包含兩個字段的表 table2,字段 id 為長整型,字段 mytext 為文本

代碼如下:

create table table2 (id long, mytext text)

用以下語句建立 table1 和 table2 的一對多關系,級聯(lián)更新,級聯(lián)刪除:

代碼如下:

alter table table2 add constraint relation1 foreign key ([id]) references table1 ([id]) on update cascade on delete cascade

刪除關系用以下語句:

代碼如下:

alter table table2 drop constraint relation1

刪除 table1 用以下語句:

代碼如下:

drop table table1

設定某字段為主鍵

代碼如下:

alter table 表1 alter column [id] counter constraint myprimarykey primary key

增加一個字段 mysalary

代碼如下:

alter table aaa add column mysalary currency

刪除一個字段 mysalary

代碼如下:

alter table aaa drop column mysalary

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)