0% found this document useful (0 votes)
39 views2 pages

Create Database Alter Database SET With Rollback Alter Database Set Online Drop Database

The document discusses several SQL Server database management tasks including detaching and attaching databases, taking databases offline and online, shrinking databases, and backing up and restoring databases. It provides instructions for performing these tasks using both the command line interface and the graphical user interface in SQL Server Management Studio.

Uploaded by

rajakumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Create Database Alter Database SET With Rollback Alter Database Set Online Drop Database

The document discusses several SQL Server database management tasks including detaching and attaching databases, taking databases offline and online, shrinking databases, and backing up and restoring databases. It provides instructions for performing these tasks using both the command line interface and the graphical user interface in SQL Server Management Studio.

Uploaded by

rajakumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Database Detach and Attach:

The data and transaction log files of a database can be detached and attached to the same or
another instance of SQL server. It is useful if we want to change the database to different instance of
SQL server on same computer or to move the database.

Online and Offline Database:

Taking the database offline and online

CUI:

CREATE DATABASE dbname //create test db

ALTER DATABASE dbname SET OFFLINE WITH ROLLBACK IMMEDIATE //taking DB offline

ALTER DATABASE dbname SET ONLINE //taking DB online

DROP DATABASE dbname //clean up

GUI:

1. Open SSMS
2. Connect to Database engine using DB administrator credentials
3. Expand Server node
4. To take databse offline, Right click Databases -> Select Tasks -> Take Offline
5. To bring back online, Right click Databases -> Select Tasks -> Bring Online.

SHRINK DB:

To reduce the size of the databse, use shrink

GUI:

1. Open SSMS
2. Connect to Database engine using DB administrator credentials
3. Expand Server node
4. Expand Databases and Right click the database that we want to shrink.
5. Point to Tasks-> Shrink and then click Database.
6. Click OK

CUI:

DBCC SHRINKDATABSE
( database_name | database_id | 0
[ , target_percent ]
[ , { NOTRUNCATE | TRUNCATEONLY } ]
)
[ WITH NO_INFOMSGS ]
Database backup and Restoring:
 Backing up is the only way to protect our data.
Database backup:
1. Open SSMS
2. Connect to Database engine using DB administrator credentials
3. Expand Server node
4. Right click Databases and point to Tasks-> Click Backup

The backup databse dialog box will appear.


5. In the Database dropdown list, verify database name.
6. Recovery model text box is reference only. We can perform a database backup for any recovery
model(Full, Bulk-Logged or Simple)
7. In the Backup type Dropdown list, Select Full.
8. Optionally, you can select the Copy-only backup checkbox to create a copy-only backup.
9. For Backup component, select the Database radio button.
10. In the Destination section, use the Back up to drop-down list to select the backup destination.
Click Add to add additional backup objects and/or destinations.
To remove a backup destination, select it and click Remove. To view the contents of an existing
backup destination, select it and click Contents.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy