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