access數(shù)據(jù)庫用sql語句添加字段,修改字段,刪除字段
來源:易賢網(wǎng) 閱讀:1449 次 日期: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 的一對多關(guān)系,級聯(lián)更新,級聯(lián)刪除:

代碼如下:

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

刪除關(guān)系用以下語句:

代碼如下:

alter table table2 drop constraint relation1

刪除 table1 用以下語句:

代碼如下:

drop table table1

設(shè)定某字段為主鍵

代碼如下:

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技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn)

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