SQL Server Database Basics

Source: Internet
Author: User
Tags mssqlserver

1 • Services to control the database

Run cmd

In the Control Panel, enter net start MSSQLserver (Start database service)

In Control Panel, enter net stop MSSQLserver (Shutdown database service)

Enter net continue MSSQLserver (continue database service) in Control Panel

"Alphabetic case can be"

    

    

2 · database file type

. MDF is a database file

. LDF is the database operation log

. NDF is a database secondary file (generally useless)

3 SQL commonly used data types

Char (Ten) character, 10 for byte length, can be changed

DateTime Date-time type     

Decimal (18,0) floating point, 18 indicates the number of integers, can be changed, 0 indicates the number of decimal digits, can be changed  

float float , accurate to 15 decimal places     

Image text graphic type, used to store large amounts of binary data, typically OLE and embedded objects such as graphics     

int integral type

Text graphic type for storing large amounts of text data

Varchar ( character type )

Varchar (MAX) character type

Xml

4 · Create a database, table

CREATE DATABASE QQ-- creating databases

Go

Use QQ-- Select Database

Go

CREATE TABLE Shuiguo-- Creating Tables

(

Code int,-- column name + data type, comma delimited

Name Char (10),

Jiage Decimal (18.2),

Chandi Char (10)

)

5 · Delete database drop databases QQ

6 • Modify the database name, preceded by the old name, followed by the new name sp_renamedb qq,abc

7 • Backup and restore

Backup of the database

Right-click database name ---> tasks ---> backup ---> Backup Type Select Full, copy-only backup, backup set expires later than a few days ---> additional ---> Select Path, write file name, and suffix . bak---> OK

    

    

    

  

Restoring a Database

Restore database in the right-click Database ---> target database name is the same as the database name of the backup ---> source Device, select the path of the database after backup, select and determine

    

    

8 • Separation and attachment

Separation of databases

Right-click the database name to detach---> Tasks---> Detach (delete link, UPDATE STATISTICS)---> OK

    

Attaching the database

Right-click Database Attach---> Add (Find database path)---> OK

    

SQL Server Database Basics

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.