SQL Server Basic Operations

Source: Internet
Author: User

SQL Server Basic Operations
Creation of a database
1. Open the SSMS tool and connect to SQL Server. Right-click "Database"-"New Database"

2. Specify the new database name, owner. (When you create a new database, the system automatically creates a primary data file and a transaction log file, such as. The master data file is the primary file of the database, which contains the startup information of the database, the files that point to the other database, and the transaction log files are used to record database operations for database recovery.

3. Click "Add" to add a secondary data file to the database. (When the database's primary data file is filled with data, the database system stores the data in the secondary data file.) There can be only one primary data file, and a secondary data file may have multiple

Extending the database (for database expansion)
1. Right click on "Database Name"-Select Click "Properties"

2. You can expand the initial size of the database, or click the "..." button on the right to set the automatic growth of the data file.


Shrinking a Database
When the database is used for a period of time, often due to data deletion caused by excessive database idle space, we can use the method of shrinking the database space occupied by the disk space to be used by other programs of the system.
1. Right click on "database Name"-"task"-"shrink". (There are two options: shrinking a database or shrinking a file.) The difference is that shrinking the database does not shrink the file to a smaller size than the original, and shrinking the file can do it.

2, you can also in the properties of the database-click on the "Options"-drop-down to find automatic contraction-the "false" in its options to "true" configuration automatically shrink the database.

detaching databases and attaching databases
Separating and attaching a database is what we often call a database move. In a working environment, where companies replace hardware devices for databases, we can attach databases to new devices by separating them and saving them in storage. Note that both the primary data file and the secondary data file must be available when the database is attached (all data files).
1. Click

2. Tick "Close connection", "UPDATE STATISTICS"-OK separation

3. Right-click "Database Name"-select "Attach"

4. Add

5. Locate the primary data file where the database is stored-determine the additional

Deleting a database
1. Right Button-"delete"

2, in order to avoid the customer is connected to the database can not be deleted, tick on the "Close existing connection"

SQL Server Basic Operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.