Operation of the database:
Backup, restore, detach, attach
Backup: Right-click on the task on the database to be backed up and select Backup. In the Punch-in dialog box, select as needed. Note: The backup expiration time cannot be 0, or it will expire immediately. The target can be placed in any position as needed. Finally, click OK and the backup is successful.
Restore: Right-click on the database to select Restore Database, write a name on the target database that is not the same as the other database, locate the MDF file of the database you want to restore in the source device below . Finally, click OK to restore the success.
Detach: Right-click on the task on the database to be detached, select Detach, tick Delete link, click OK, detach successfully.
Attach: On the database right click Attach, in the Open dialog box click Add, find the database to attach the MDF file, click OK two times.
Backup file (. bak) for the database
Data file (. mdf) for the database
Log file (. ldf) for the database
Query statements
Create Database Shu-- creating a db named Shu
Go--go is a cohesive, dispensable
Use Shu-- using the Shu database
Go
Drop Database Shu-- Delete the databases Shu
Go
CREATE TABLE Shubiao-- creates a sheet named shubiao , don't forget the parentheses
(
Study number int NOT NULL,-- whether the column name data type can be null, is not write
Name varchar (10),
Age int,
Birthday datetime,
Sex varchar (10)
)
ALTER TABLE Shubiao Add other varchar-- Add a column to the table
ALTER TABLE Shubiao add comment varchar (NOT null)
ALTER TABLE Shubiao drop column Other-- delete one of the columns in the table
DROP table Shubiao-- Delete entire table
INSERT into Shubiao values (1, ' Zhang San ', +, ' 1990 5 1 ', ' male ')-- add a whole piece of data to the table
INSERT into Shubiao values (2, ' John Doe ', $, ' 1989 8 ', ' male ')
INSERT into Shubiao values (3, ' Harry ', +, ' 1985 1 ', ' male ')
INSERT into Shubiao values (4, ' Zhao Liu ', +, ' 1980 9 ', ' male ')
Insert into Shubiao (school number, name, gender) VALUES (5, ' Zhuge Liang ', ' men ')-- add data that is not NULL in the table
Select *from Shubiao-- querying all data in a table
Update Shubiao Set study number =110-- Modify the "school number" This column of data is changed to "
Update Shubiao set study number =120 where name = ' Zhang San ' -- Change the column of "number" in this line of "name" to "Zhang San" to "
Delete from Shubiao- deletes data from the entire table (data is deleted only)
Delete from Shubiao where name = ' Zhang San ' -- Delete this row of data with "name" as "Harry"
SQL Statement 2