1, backup
<%
SQL = "Backup Database Database name to disk = '" & server.mappath ("backup") & "/" & "backuptext.dat" & "" "
SET CNN = Server.createObject ("AdoDb.Connection")
CNN.Open "driver = {SQL Server}; server = server name; uid = sa; pwd ="
CNN.Execute SQL
ON Error ResMe next
IF Err <> 0 THEN
Response.write "error:" & Err.Descripting
Else
Response.write "Data Backup Success!"
END IF
%>
2, restore
<%
SQL = "Restore Database Database name from disk = '" & server.mappath ("backup") & "/" & "backuptext.dat" & "" "
SET CNN = Server.createObject ("AdoDb.Connection")
CNN.Open "driver = {SQL Server}; server = server name; uid = sa; pwd ="
CNN.Execute SQL
ON Error ResMe next
IF Err <> 0 THEN
Response.write "error:" & Err.Descripting
Else
Response.write "data recovery is successful!"
END IF
%>
Note: The above statement is to backup data into the backup directory of the disk, the file name is BackupText.dat.
2, can the SQL database structure can be modified in the ASP?
A: ALTER TABLE
name
ALTER TABLE - Change Table Properties
grammar
Alter Table Table [*]
Add [Column] Column Type
Alter Table Table [*]
Alter [column] column {set default value | DROP DEFAULT}
Alter Table Table [*]
Rename [column] column to newcolumn
Alter Table Table
Rename to newTable
Alter Table Table
Add Table Constraint Definition
INPUTS
TABLE
Attempting to change the name of the existing table.
Column
Existing or new column names.
Type
The type of new column.
NewColumn
The new name of the existing columns.
NewTable
A new name of the table.
Table consTRAINT Definition
A new constraint definition of the table.
New Table Constraint for the Table
Output
ALTER
Information returned from the renamed column or table.
Error
If a column or the table does not exist.
description
ALTER TABLE Changes the definition of an existing table. The Add Column is used to add a norm / field in the form of Create Table. Alter column allows you to set or delete the default (value) from the column / field. Note that the default (value) is only valid for newly inserted rows. The rename clause can change a table or column / field name without affecting any data in the related table. Therefore, the table or column / field will still be the same size and type after this command is executed. The Add Table Constraint definition clause adds a new constraint to the table as the CREATE TABLE. If you want to change the properties of the table, you must be the owner of the table.
note
The COLUMN keyword is redundant and can be omitted.
If "*" is followed behind a table name, it means that the command is to operate on the table and all inheritance levels below the table; the attribute (change) does not increase to any child table or modify any The relevant name of the sub-table. It is always like this when an attribute of an increase or modification of a superior table (translation: inherited level is high). Otherwise, in the inheritance level, in the following
Select NewColumn from Superclass *
Will you work because the subtray will be less attribute than the top-level.
In the current implementation, the default (value) of the new column / field and the constraint subsis will be ignored. You can then set the default (value) in the form of ALTER TABLE's Set Default. (You have to use Update to update existing rows to default.)
In the current implementation, only the Foreign Key constraint can be added to the table. To create or delete a unique constraint, you can create a unique index (see CREATE INDEX). To add Check (check) constraints, you need to rebuild and overload the table, and the parameters used are other parameters of the CREATE TABLE command.
To modify the structure of the table, you must be the owner of the table. No part of the system table structure is not allowed. The PostgreSQL user manual has more information about inheritance.
Please refer to the description of more valid parameters for the CREATE TABLE section.
usage
Add a VARCHAR column to the table:
ALTER TABLE DISTRIBUTORS ADD Column Address VARCHAR (30);
Remarks of existing column:
Alter Table Distributors rename column address to city;
Rename the existing table:
Alter Table Distributors rename to support;
Add a foreign key constraint to the table:
ALTER TABLE DISTRIBUTORS Add Constraint Distfk Foreign Key (Address) References Addresses (Address) Match Full
compatibility
The SQL92Add Column form is compatible, except for the default (value) and constraints mentioned above. The ALTER column form is fully compatible.
SQL92 declares some additional Postgres for ALTER TABLE:
ALTER TABLE TABLE DROP CONSTRAINT CONSTRAINT {rate | cascade}
Increase or delete the constraints of the table (such as an image check constraint, unique constraint or foreign key constraint). To create or delete a unique constraint, create or delete a unique index, modify other types of constraints, you need to rebuild and overload the table, using the CREATE TABLE command to use other parameters. For example, delete any constraints of table distributors:
CREATE TABLE TEMP AS SELECT * from Distributors;
DROP TABLE DISTRIBUTORS;
Create Table Distributors as SELECT *.
Drop Table Temp;
Alter Table Table Drop [Column] Column {Restrict | Cascade}
Before, delete an existing column, the table must be recreated and reloaded:
Create Table Temp as SELECT DID, City from Distributors;
DROP TABLE DISTRIBUTORS;
Create Table Distributors
DID DECIMAL (3) Default 1,
Name varchar (40) Not null,
);
INSERT INTO Distributors Select * from Temp;
Drop Table Temp;
The redmit column / field and table name are PostgreSQL extensions. SQL92 did not provide this.