DBCC (Database base consistency Checker, consistency checker for databases) commands are used to verify database integrity, find errors, and analyze system usage.
1.DBCC checkalloc
Use the DBCC checkalloc command to detect the consistency of the practice database disk space allocation structure.
Code:
DBCC checkalloc ('practice')
Effect:
2.DBCC Showconfig
Use the DBCC SHOWCONFIG command to display fragmentation information for the data and indexes of the specified table.
3.CHECKPOINT
4.DECLARE
The declare command is used to declare one or more local variables, cursor variables, or table variables.
Note: If the defined variable is a character type, you should specify its maximum length in the data_type expression, or the system considers its length to be 1.
DECLARE @x int,@y char (8), @z datetime
5.PRINT
The Print command returns a user-defined message to the client that displays the contents of a string (up to 255 characters), a local variable, or a global variable.
PRINT | @local_variable | string_expr
Code:
1 Char () 2 set @x=' no longer makes you lonely '3print @x4' Favorite movie '[email protected]
Effect:
6.RAISERROR
The RAISERROR command is used to return the user-specified information when an error message is returned in the SQL Server system
7.READTEXT
The READTEXT command reads the value in the text, ntext, or image column, starting at the specified position to read the specified number of characters.
The format is as follows:
READTEXT {table. column [HOLDLOCK]
8.BACKUP
The backup command is used to back up the database content or its transaction log to the storage media.
Code:
Backup DATABASE to Disk = ' Backup.bak '
9.RESTORE
The restore command is used to restore the database or its transaction log backup files from the storage media to the SQL Server system.
RESTORE DATABASE from Disk = ' Backup.bak ' with Replace
10.SELECT
Code:
1 Use Practice 2 Declare @Name Char () 3 Select @Name = Name 4 from Info_borrow 5 PRINT @Name
Effect:
11.SET
Code:
1 Declare @x int 2 Set @x = 9 3 Print @x
Effect:
12.USE
Use command to open or close a database in the previous workspace
use {database}
Code:
1 Use Practice 2 Select * from Info_stu
Effect:
SQL Server Common commands