SQL Server database Basics

Source: Internet
Author: User
Tags mssqlserver
1. Run cmd to control database services. On the control panel, enter netstartMSSQLserver (start Database Service). On the control panel, enter netstopMSSQLserver (close Database Service). On the control panel, enter netcontinueMSSQLserver (continue Database Service) [uppercase/lowercase letters] 2. database file type. mdf is a database file. ldf is

1. Run cmd to control database services. On the control panel, enter netstart MSSQLserver (start Database Service). On the control panel, enter netstop MSSQLserver (close Database Service). On the control panel, enter netcontinueMSSQLserver (continue Database Service) [uppercase/lowercase letters] 2. database file type. mdf is a database file. ldf is

1. Database Control Services

Run cmd

On the Control Panel, enter net start MSSQLserver to start the database service)

On the Control Panel, enter net stop MSSQLserver (disable Database Service)

On the Control Panel, enter net continue MSSQLserver (continue Database Service)

[Uppercase/lowercase letters]

    

    

2. Database File Types

. Mdf is a database file

. Ldf is the database operation log

. Ndf is a secondary database file (generally useless)

3. Common SQL data types

Char (10) bytes, 10 indicates the byte length, which can be changed

Datetime type

Decimal () floating point type, 18 indicates the number of digits, can be changed; 0 indicates the number of Decimal places, can be changed

Float, accurate to 15 decimal places

Image Text Graphics, used to store a large amount of binary data, usually for graphics and other ole and embedded objects

Int integer

Text Graphics, used to store a large amount of Text data

Varchar (50) balanced

Varchar (MAX) connector

Xml

4. create databases and tables

Create database qq -- create a database

Go

Use qq -- select database

Go

Create table shuiguo -- create a table

(

Code int, -- column name + data type, separated by commas

Name char (10 ),

Jiage decimal (18.2 ),

Chandi char (10)

)

5. drop database qq

6. Modify the database name. The old name is followed by the new name sp_renamedb qq and abc.

7. Backup and Restoration

Database Backup

Right-click the database name ---> task ---> Backup ---> select complete Backup Type, copy only backup, backup set expiration time later than any day ---> additional ---> select path, Write File Name and suffix. bak ---> OK

    

    

    

  

Database Restoration

Right-click Restore database in the database ---> the name of the target database must be the same as that of the backup database ---> source device, select the path of the backup database, select and confirm

    

    

8. Separation and Addition

Database Separation

Right-click the name of the database to be detached ---> task ---> detach (delete link, update statistics) ---> OK

    

Database appending

Right-click Database attach ---> Add (find database path) ---> OK

    

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.