ASP中怎麼實現SQL資料庫備份 恢復!

2021-05-01 20:37:59 字數 2271 閱讀 8171

選擇自 hanghwp 的 blog

注:以上語句是把資料備份到磁碟的backup目錄下,檔名為backuptext.dat。

2、asp中能修改sql資料庫結構嗎?

答:alter table

名稱alter table — 更改表屬性

語法alter table table [ * ]

add [ column ] column type

alter table table [ * ]

alter [ column ] column

alter table table [ * ]

rename [ column ] column to newcolumn

alter table table

rename to newtable

alter table table

add table constraint definition

inputs

table

試圖更改的現存表的名稱 www.knowsky.com.

column

現存或新的列名稱.

type

新列的型別.

newcolumn

現存列的新名稱.

newtable

表的新名稱.

table constraint definition

表的新的約束定義.

new table constraint for the table

輸出alter

從被更名的列或表返回的資訊.

error

如果乙個列或表不存在返回的資訊.

描述alter table 變更乙個現存表的定義.add column 形式用與 create table一樣的語法向表中增加乙個新列/字段。alter column 形式允許你從列/欄位中設定或者刪除預設(值)。注意預設(值)只對新插入的行有效。rename 子句可以在不影響相關表中任何資料的情況下更改乙個表或者列/欄位的名稱。因此,表或列/欄位在此命令執行後仍將是相同尺寸和型別。add table constraint definition 子句用與 create table一樣的語法向表中增加乙個新的約束。

如果要改變表的屬性,你必須是表的所有者.

注意column 關鍵字是多餘的,可以省略.

如果"*"跟在乙個表名後面,表示該命令要對該錶和所有繼承級別低於該錶的表進行操作;預設時,該屬性(更改)不會增加到任何子表或修改任何子表的相關名稱。當增加或修改乙個上級表(譯註:繼承級別高的表)的屬性時總是應該這樣的。否則,象下面這樣的在繼承級上進行的查詢

select newcolumn from superclass*

將不能工作,因為子表會比上級表少乙個屬性。

在目前的實現裡,新列/欄位的預設(值)和約束子句會被忽略。你可以隨後用 alter table 的 set default 形式設定預設(值)。(你還不得不用 update 把已存在行更新為預設值。)

在目前的實現裡,只有 foreign key 約束可以增加到表中.要建立或者刪除乙個唯一約束,可以建立乙個唯一索引(參閱 create index).要想增加 check (檢查)約束,你需要重建和過載該錶,用的引數是 create table 命令的其他引數.

要修改表的結構,你必須是表的所有人。不允許更改系統表結構的任何部分。postgresql 使用者手冊 裡有關於繼承的更多資訊.

用法向表中增加乙個 varchar 列:

alter table distributors add column address varchar(30);

對現存列改名:

alter table distributors rename column address to city;

對現存表改名:

alter table distributors rename to suppliers;

向表中增加乙個外來鍵約束:

alter table distributors add constraint distfk foreign key (address) references addresses(address) match full

相容性sql92add column 形式是相容的,除了上面說的預設(值)和約束外。alter column 形式是完全相容的。

sql92 對 alter table 宣告了一些附加的postgres目前還不直接支援的功能:

alter table table drop constraint constraint

增加

ASP中怎麼實現SQL資料庫備份 恢復!

注 以上語句是把資料備份到磁碟的backup目錄下,檔名為backuptext.dat。2 asp中能修改sql資料庫結構嗎?答 alter table 名稱alter table 更改表屬性 語法alter table table add column column type alter tabl...

asp連線sql資料庫,access資料庫字串

asp連線sqlserver資料庫字串 set connsql server.createobject adodb.connection strsql provider sqloledb.1 password y ht1986 persist security info true user id s...

ASP和SQL資料庫聯

現在asp和sql資料庫聯絡緊密,包括access資料庫,資料庫的執行效率直接關係著你系統的執行質量,因此優化好你的資料庫,是很有必要的,下面介紹幾種sqlserver access優化方法,對使用asp的朋友,或許會有不小幫助。方法一 要使用復合sql查詢,不要使用單一堆徹的大量簡單sql,因為乙...